OSDN Git Service

PR c++/46289
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Nov 2010 19:13:27 +0000 (19:13 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Nov 2010 19:13:27 +0000 (19:13 +0000)
* semantics.c (build_constexpr_constructor_member_initializers):
Avoid ICE on error.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166270 138bc75d-0d04-0410-961f-82ee72b054a4

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

index cac8a1a..7c4b082 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46289
+       * semantics.c (build_constexpr_constructor_member_initializers):
+       Avoid ICE on error.
+
 2010-11-02  Dodji Seketeli  <dodji@redhat.com>
 
        * cp-tree.h (enum tsubst_flags)<tf_no_class_instantiations>:
index 3215410..562fab1 100644 (file)
@@ -5507,10 +5507,9 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
     body = BIND_EXPR_BODY (body);
   if (TREE_CODE (body) == CLEANUP_POINT_EXPR)
     ok = build_data_member_initialization (body, &vec);
-  else
+  else if (TREE_CODE (body) == STATEMENT_LIST)
     {
       tree_stmt_iterator i;
-      gcc_assert (TREE_CODE (body) == STATEMENT_LIST);
       for (i = tsi_start (body); !tsi_end_p (i); tsi_next (&i))
        {
          ok = build_data_member_initialization (tsi_stmt (i), &vec);
@@ -5518,6 +5517,8 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
            break;
        }
     }
+  else
+    gcc_assert (errorcount > 0);
   if (ok)
     return build_constructor (type, vec);
   else
index 26555d7..a2e1330 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46289
+       * g++.dg/cpp0x/constexpr-ice3.C: New.
+
 2010-11-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/opt8.ad[sb]: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C
new file mode 100644 (file)
index 0000000..23903bc
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/46289
+// { dg-options -std=c++0x }
+
+struct A
+{
+  int i;
+};
+
+struct B
+{
+  A a;
+  constexpr B(): a({1,2}) { }  // { dg-error "" }
+};