aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-07-06 11:23:59 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-07-06 11:23:59 +0000
commit004e2fa73b7677e460c760878469d7a6c3759ea4 (patch)
treef38d084dfce120ac3285b6703630b8c744802276 /gcc
parentc7ff6e7a7a943f9eed6a66dd41c8e35e9df2bf6c (diff)
downloadgcc-004e2fa73b7677e460c760878469d7a6c3759ea4.zip
gcc-004e2fa73b7677e460c760878469d7a6c3759ea4.tar.gz
gcc-004e2fa73b7677e460c760878469d7a6c3759ea4.tar.bz2
gimplify.c (gimplify_call_expr): Prefer DECL_ARGUMENTS over TYPE_ARG_TYPES for verification of argument types.
2007-07-06 Richard Guenther <rguenther@suse.de> * gimplify.c (gimplify_call_expr): Prefer DECL_ARGUMENTS over TYPE_ARG_TYPES for verification of argument types. Use DECL_ARG_TYPE instead of the PARM_DECL type. Take excess parameters as variable arguments. * g++.dg/opt/pr30965.C: New testcase. From-SVN: r126412
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimplify.c35
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/opt/pr30965.C20
4 files changed, 52 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6fab540..f405b26 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-06 Richard Guenther <rguenther@suse.de>
+
+ * gimplify.c (gimplify_call_expr): Prefer DECL_ARGUMENTS over
+ TYPE_ARG_TYPES for verification of argument types. Use
+ DECL_ARG_TYPE instead of the PARM_DECL type. Take excess
+ parameters as variable arguments.
+
2007-07-06 Andreas Krebbel <krebbel1@de.ibm.com>
* libgcc2.h (word_type): Type definition removed.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 5510f60..dd3d5fa 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2135,7 +2135,27 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
/* Verify if the type of the argument matches that of the function
declaration. If we cannot verify this or there is a mismatch,
mark the call expression so it doesn't get inlined later. */
- if (parms)
+ if (decl && DECL_ARGUMENTS (decl))
+ {
+ for (i = 0, p = DECL_ARGUMENTS (decl); i < nargs;
+ i++, p = TREE_CHAIN (p))
+ {
+ /* We cannot distinguish a varargs function from the case
+ of excess parameters, still defering the inlining decision
+ to the callee is possible. */
+ if (!p)
+ break;
+ if (p == error_mark_node
+ || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
+ || !fold_convertible_p (DECL_ARG_TYPE (p),
+ CALL_EXPR_ARG (*expr_p, i)))
+ {
+ CALL_CANNOT_INLINE_P (*expr_p) = 1;
+ break;
+ }
+ }
+ }
+ else if (parms)
{
for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
{
@@ -2154,19 +2174,6 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
}
}
}
- else if (decl && DECL_ARGUMENTS (decl))
- {
- for (i = 0, p = DECL_ARGUMENTS (decl); i < nargs;
- i++, p = TREE_CHAIN (p))
- if (!p
- || p == error_mark_node
- || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
- || !fold_convertible_p (TREE_TYPE (p), CALL_EXPR_ARG (*expr_p, i)))
- {
- CALL_CANNOT_INLINE_P (*expr_p) = 1;
- break;
- }
- }
else if (nargs != 0)
CALL_CANNOT_INLINE_P (*expr_p) = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a630290..4d5e688 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-07-06 Richard Guenther <rguenther@suse.de>
+
+ * g++.dg/opt/pr30965.C: New testcase.
+
2007-07-06 Richard Sandiford <richard@codesourcery.com>
* gcc.target/mips/save-restore-5.c: New test.
diff --git a/gcc/testsuite/g++.dg/opt/pr30965.C b/gcc/testsuite/g++.dg/opt/pr30965.C
new file mode 100644
index 0000000..c41cf91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr30965.C
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+
+#include <tr1/functional>
+#include <algorithm>
+
+extern void assign( long* variable, long v )
+{
+ std::transform( variable, variable + 1, variable,
+ std::tr1::bind( std::plus< long >(), 0L, v ) );
+}
+extern void assign( long& variable, long v )
+{
+ std::transform( &variable, &variable + 1, &variable,
+ std::tr1::bind( std::plus< long >(), 0L, v ) );
+}
+
+/* { dg-final { scan-tree-dump-times ";; Function" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "variable = v" 2 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */