re PR middle-end/78716 (ICE in gimplify_va_arg_expr, at gimplify.c:12650 (i686-linux...
authorMarek Polacek <polacek@redhat.com>
Mon, 12 Dec 2016 13:57:32 +0000 (13:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 12 Dec 2016 13:57:32 +0000 (13:57 +0000)
PR middle-end/78716
* gimplify.c (gimplify_va_arg_expr): Don't require ADDR_EXPR for
Case 1; check POINTER_TYPE_P instead.

* g++.dg/other/vararg-5.C: New.

From-SVN: r243553

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/vararg-5.C [new file with mode: 0644]

index 1dc690f42cb12a36cacdc86091a28a5fb73d1bbe..81b0a3b48e769b6cd3c3109742b45cab8f17b855 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-12  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/78716
+       * gimplify.c (gimplify_va_arg_expr): Don't require ADDR_EXPR for
+       Case 1; check POINTER_TYPE_P instead.
+
 2016-12-12  Bernd Schmidt  <bschmidt@redhat.com>
 
        PR rtl-optimization/78669
index 8611060aea677215f73f26cc36e93541418486ec..b738855a63754afdb47aa945f44dbde09fef2abe 100644 (file)
@@ -12643,7 +12643,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p,
     return GS_ERROR;
   have_va_type = targetm.canonical_va_list_type (have_va_type);
   if (have_va_type == NULL_TREE
-      && TREE_CODE (valist) == ADDR_EXPR)
+      && POINTER_TYPE_P (TREE_TYPE (valist)))
     /* Handle 'Case 1: Not an array type' from c-common.c/build_va_arg.  */
     have_va_type
       = targetm.canonical_va_list_type (TREE_TYPE (TREE_TYPE (valist)));
index 66407ff05d98da17a770f3a2fa181778278c22ac..588c51bd1409eaae557316bbe69bbd11a83c8cb9 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-12  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/78716
+       * g++.dg/other/vararg-5.C: New.
+
 2016-12-12  Bernd Schmidt  <bschmidt@redhat.com>
 
        PR rtl-optimization/78669
diff --git a/gcc/testsuite/g++.dg/other/vararg-5.C b/gcc/testsuite/g++.dg/other/vararg-5.C
new file mode 100644 (file)
index 0000000..9327bd6
--- /dev/null
@@ -0,0 +1,24 @@
+// PR middle-end/78716
+// { dg-do compile }
+
+template <typename = int, typename = int, typename = int, typename = int,
+                  typename = int>
+                  struct a;
+                  template <typename> struct b;
+                  template <typename = int, typename d = void> class e : b<d>::c {
+                    public:
+                        typedef e f;
+                          typedef typename b<d>::c g;
+                            e(__builtin_va_list *s) : g(__builtin_va_arg(*s, int)) {}
+                  };
+template <> struct b<void> { typedef e<> c; };
+template <> struct e<> { template <typename h> e(h); };
+template <typename i> class a<i> : public e<i> {};
+template <typename i, typename j, typename k, typename l>
+class a<i, j, k, l> : e<typename a<j>::f> {
+  public:
+      template <typename m, typename n, typename o, typename p>
+         a(a<m, n, o, p>) : a::f(0) {}
+};
+template <typename i, typename j, typename k, typename l> a<> r(i, j, k, l);
+void q() { a<float, float>(r(4, 6, 9, 7)); }