re PR c++/61994 (constexpr vector array ICE)
authorJason Merrill <jason@redhat.com>
Thu, 7 Aug 2014 01:44:06 +0000 (21:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 7 Aug 2014 01:44:06 +0000 (21:44 -0400)
PR c++/61994
* init.c (build_vec_init): Leave atype an ARRAY_TYPE
if we're just returning an INIT_EXPR.

From-SVN: r213688

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/g++.dg/cpp0x/constexpr-array7.C [new file with mode: 0644]

index 285f058556091217e0d5f658ee2a0faf5e189a9e..9ffd7468563843a997f7ce73b4f086a201ef2b30 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/61994
+       * init.c (build_vec_init): Leave atype an ARRAY_TYPE
+       if we're just returning an INIT_EXPR.
+
 2014-08-06  Jason Merrill  <jason@redhat.com>
            Braden Obrzut  <admin@maniacsvault.net>
 
index eeee5bb362033b7f0d06baa8467609e511c81cb1..17e6c4becb56a76e47df1e878fdfcaf55ba4c2e7 100644 (file)
@@ -3840,6 +3840,13 @@ build_vec_init (tree base, tree maxindex, tree init,
 
   stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt);
 
+  current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
+
+  if (errors)
+    return error_mark_node;
+  if (const_init)
+    return build2 (INIT_EXPR, atype, obase, const_init);
+
   /* Now make the result have the correct type.  */
   if (TREE_CODE (atype) == ARRAY_TYPE)
     {
@@ -3849,12 +3856,6 @@ build_vec_init (tree base, tree maxindex, tree init,
       TREE_NO_WARNING (stmt_expr) = 1;
     }
 
-  current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
-
-  if (const_init)
-    return build2 (INIT_EXPR, atype, obase, const_init);
-  if (errors)
-    return error_mark_node;
   return stmt_expr;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array7.C
new file mode 100644 (file)
index 0000000..8f74675
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/61994
+// { dg-do compile { target c++11 } }
+
+struct A { int i,j; };
+
+struct X {
+  A a = {1,1};
+};
+
+constexpr X table[1][1] = {{ {} }};
+
+#define SA(X) static_assert(X,#X)
+SA(table[0][0].a.i == 1);