]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/70084 (va_arg ((ap), int) regression on s390*-*)
authorJakub Jelinek <jakub@redhat.com>
Sat, 5 Mar 2016 06:50:23 +0000 (07:50 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 5 Mar 2016 06:50:23 +0000 (07:50 +0100)
PR c++/70084
* tree-inline.c (copy_tree_body_r): When cancelling ADDR_EXPR
of INDIRECT_REF and ADDR_EXPR changed type, fold_convert it
to the right type.

* g++.dg/expr/stdarg3.C: New test.

From-SVN: r234004

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/stdarg3.C [new file with mode: 0644]
gcc/tree-inline.c

index 7d2034bbca2b9c69cc033aa4747256a20d06cfe9..1c775b255a6abbdd87f8a06dc1d1d13a417e48e8 100644 (file)
@@ -1,3 +1,10 @@
+2016-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/70084
+       * tree-inline.c (copy_tree_body_r): When cancelling ADDR_EXPR
+       of INDIRECT_REF and ADDR_EXPR changed type, fold_convert it
+       to the right type.
+
 2016-03-04  Bernd Schmidt  <bschmidt@redhat.com>
 
        PR c/69973
index 4b08dcd7a04f4f875ecd599ce061a1e237bed5f3..808b0c8c31fcb0ff9e34bd9db519a3278bab05a7 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/70084
+       * g++.dg/expr/stdarg3.C: New test.
+
 2016-03-04  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/69196
diff --git a/gcc/testsuite/g++.dg/expr/stdarg3.C b/gcc/testsuite/g++.dg/expr/stdarg3.C
new file mode 100644 (file)
index 0000000..97aade0
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/70084
+// { dg-do compile }
+
+#include <stdarg.h>
+
+struct A
+{
+  A (const char *f, ...);
+};
+
+A::A (const char *f, ...)
+{
+  va_list ap;
+  va_start (ap, f);
+  int i = va_arg (ap, int);    // { dg-bogus "first argument to 'va_arg' not of type 'va_list'" }
+  int j = va_arg ((ap), int);  // { dg-bogus "first argument to 'va_arg' not of type 'va_list'" }
+  va_end (ap);
+}
index 073c1c78877c7025c086572fb867fb7a23825cf7..d52e0c6e20275c42018fc9b7a02e884476cc1edb 100644 (file)
@@ -1266,7 +1266,12 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data)
          /* Handle the case where we substituted an INDIRECT_REF
             into the operand of the ADDR_EXPR.  */
          if (TREE_CODE (TREE_OPERAND (*tp, 0)) == INDIRECT_REF)
-           *tp = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0);
+           {
+             tree t = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0);
+             if (TREE_TYPE (t) != TREE_TYPE (*tp))
+               t = fold_convert (remap_type (TREE_TYPE (*tp), id), t);
+             *tp = t;
+           }
          else
            recompute_tree_invariant_for_addr_expr (*tp);