summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-06-29 13:43:10 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-06-29 13:43:10 +0000
commit42f6e2ec11f6dabcdc48b9b6a739d05d70a8c9f7 (patch)
tree34d09710500c8001c0c549f2d207f6cd59a0b876 /gcc
parent29fbecf33f017563e0e5488188d23b32a38bcbeb (diff)
downloadgcc-42f6e2ec11f6dabcdc48b9b6a739d05d70a8c9f7.tar.gz
re PR middle-end/32493 (Fails to inline varargs function with unused arguments)
2006-06-29 Richard Guenther <rguenther@suse.de> PR middle-end/32493 * gimplify.c (gimplify_call_expr): Ignore variable argument parts during type verification. * gcc.dg/inline-23.c: New testcase. From-SVN: r126113
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c21
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/inline-23.c17
4 files changed, 42 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 653c69618f3..3aef4385487 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-29 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/32493
+ * gimplify.c (gimplify_call_expr): Ignore variable argument parts
+ during type verification.
+
2007-06-29 Jan Hubicka <jh@suse.cz>
* recog.c (validate_change_rtx_1): Unshare TO argument.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d935ec17f6e..a7669acc968 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2138,14 +2138,21 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
if (parms)
{
for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
- if (!p
- || TREE_VALUE (p) == error_mark_node
- || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
- || !fold_convertible_p (TREE_VALUE (p), CALL_EXPR_ARG (*expr_p, i)))
- {
- CALL_CANNOT_INLINE_P (*expr_p) = 1;
+ {
+ /* If this is a varargs function defer inlining decision
+ to callee. */
+ if (!p)
break;
- }
+ if (TREE_VALUE (p) == error_mark_node
+ || CALL_EXPR_ARG (*expr_p, i) == error_mark_node
+ || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
+ || !fold_convertible_p (TREE_VALUE (p),
+ CALL_EXPR_ARG (*expr_p, i)))
+ {
+ CALL_CANNOT_INLINE_P (*expr_p) = 1;
+ break;
+ }
+ }
}
else if (decl && DECL_ARGUMENTS (decl))
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2ac00bf8914..9c6e0c5a3f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-29 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/32493
+ * gcc.dg/inline-23.c: New testcase.
+
2007-06-29 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/24659
diff --git a/gcc/testsuite/gcc.dg/inline-23.c b/gcc/testsuite/gcc.dg/inline-23.c
new file mode 100644
index 00000000000..171cf624a19
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/inline-23.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+/* Make sure we can inline a varargs function whose variable arguments
+ are not used. See PR32493. */
+static inline __attribute__((always_inline)) void __check_printsym_format(const
+char *fmt, ...)
+{
+}
+static inline __attribute__((always_inline)) void print_symbol(const char *fmt,
+unsigned long addr)
+{
+ __check_printsym_format(fmt, "");
+}
+void do_initcalls(void **call)
+{
+ print_symbol(": %s()", (unsigned long) *call);
+}