re PR middle-end/32493 (Fails to inline varargs function with unused arguments)
authorRichard Guenther <rguenther@suse.de>
Fri, 29 Jun 2007 13:43:10 +0000 (13:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 29 Jun 2007 13:43:10 +0000 (13:43 +0000)
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

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/inline-23.c [new file with mode: 0644]

index 653c69618f325be1c2a6a1d4027a8f723151e848..3aef438548771170bb0d9d7ad652693e222d3cf5 100644 (file)
@@ -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.
index d935ec17f6e6934d773b8dc8c919e1c1017a13c7..a7669acc9680f0dd7e03419651103d37d910fcc1 100644 (file)
@@ -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))
     {
index 2ac00bf8914b607c225cb98b51d628f87ba102b8..9c6e0c5a3f7c997a024d96f72bcfeab28255e603 100644 (file)
@@ -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 (file)
index 0000000..171cf62
--- /dev/null
@@ -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);
+}