re PR c++/58611 ([c++11] ICE with invalid constexpr constructor used in array initial...
authorJason Merrill <jason@redhat.com>
Mon, 14 Jul 2014 05:25:31 +0000 (01:25 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 14 Jul 2014 05:25:31 +0000 (01:25 -0400)
PR c++/58611
* decl.c (check_initializer): Don't finish_compound_literal
on erroneous constexpr init.

From-SVN: r212506

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

index 63f68dc2bb262db86f7270f4cf9470f37dda38d5..2918318506c18c327283e2a8cd7aa97b8c180ccc 100644 (file)
@@ -1,5 +1,9 @@
 2014-07-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/58611
+       * decl.c (check_initializer): Don't finish_compound_literal
+       on erroneous constexpr init.
+
        PR c++/58612
        * tree.c (bot_replace): Only replace a dummy 'this' parm.
 
index 8f829d09e98544240a11ffbded246718295bf4fd..9d3fbb275f6d06e5c3af8c31e29e80a5b2cdc2bb 100644 (file)
@@ -5812,11 +5812,8 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
              /* Declared constexpr, but no suitable initializer; massage
                 init appropriately so we can pass it into store_init_value
                 for the error.  */
-             if (init && BRACE_ENCLOSED_INITIALIZER_P (init))
-               init = finish_compound_literal (type, init,
-                                               tf_warning_or_error);
-             else if (CLASS_TYPE_P (type)
-                      && (!init || TREE_CODE (init) == TREE_LIST))
+             if (CLASS_TYPE_P (type)
+                 && (!init || TREE_CODE (init) == TREE_LIST))
                {
                  init = build_functional_cast (type, init, tf_none);
                  if (TREE_CODE (init) == TARGET_EXPR)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C
new file mode 100644 (file)
index 0000000..16eacdd
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/58611
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int i;
+  constexpr A() {}             // { dg-error "A::i" }
+};
+
+struct B
+{
+  A a;
+};
+
+constexpr B b[] = { {} };      // { dg-error "A::A" }