diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-21 14:25:46 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-21 14:25:46 +0000 |
commit | 62437c86b7a7212f42b4aff23bdad1dd88f2ed13 (patch) | |
tree | c29551acd700f7afa035e60d6d0bab2f9c14a3c2 | |
parent | 6fa44a4c55df01ac23549c1c6620d613c4955d26 (diff) | |
download | gcc-62437c86b7a7212f42b4aff23bdad1dd88f2ed13.tar.gz |
2008-01-21 Richard Guenther <rguenther@suse.de>
PR c/34885
* tree-inline.c (setup_one_parameter): Deal with mismatched
types using a VIEW_CONVERT_EXPR.
* gcc.c-torture/compile/pr34885.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131694 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr34885.c | 14 | ||||
-rw-r--r-- | gcc/tree-inline.c | 11 |
4 files changed, 35 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 28474ddf8a3..4b67afa8f85 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-01-21 Richard Guenther <rguenther@suse.de> + + PR c/34885 + * tree-inline.c (setup_one_parameter): Deal with mismatched + types using a VIEW_CONVERT_EXPR. + 2008-01-21 Alon Dayan <alond@il.ibm.com> Olga Golovanevsky <olga@il.ibm.com> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e15a98f6839..42a24a97ede 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-21 Richard Guenther <rguenther@suse.de> + + PR c/34885 + * gcc.c-torture/compile/pr34885.c: New testcase. + 2008-01-21 Eric Botcazou <ebotcazou@adacore.com> * gnat.dg/specs/alignment1.ads: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34885.c b/gcc/testsuite/gcc.c-torture/compile/pr34885.c new file mode 100644 index 00000000000..f5a3c13b572 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34885.c @@ -0,0 +1,14 @@ +typedef union { + __const struct sockaddr *__restrict __sockaddr__; +} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__)); +extern int _pure_socketcall (const struct sockaddr *); +extern int sendto (__CONST_SOCKADDR_ARG __addr); +int send(void) +{ + return sendto((void *)0); +} +int sendto(const struct sockaddr *to) +{ + return _pure_socketcall(to); +} + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 1fe084752bb..636e37d8024 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1444,7 +1444,16 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, if (value && value != error_mark_node && !useless_type_conversion_p (TREE_TYPE (p), TREE_TYPE (value))) - rhs = fold_build1 (NOP_EXPR, TREE_TYPE (p), value); + { + if (fold_convertible_p (TREE_TYPE (p), value)) + rhs = fold_build1 (NOP_EXPR, TREE_TYPE (p), value); + else + /* ??? For valid (GIMPLE) programs we should not end up here. + Still if something has gone wrong and we end up with truly + mismatched types here, fall back to using a VIEW_CONVERT_EXPR + to not leak invalid GIMPLE to the following passes. */ + rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (p), value); + } /* If the parameter is never assigned to, has no SSA_NAMEs created, we may not need to create a new variable here at all. Instead, we may |