Another ICE-on-invalid where we should check for error_mark_node otherwise
we're toast.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-03-02  Marek Polacek  <pola...@redhat.com>

        PR c++/84663
        * decl.c (cp_complete_array_type): Check error_mark_node.

        * g++.dg/parse/array-size3.C: New test.

diff --git gcc/cp/decl.c gcc/cp/decl.c
index 735ed5d63d2..1866e8f3574 100644
--- gcc/cp/decl.c
+++ gcc/cp/decl.c
@@ -8323,7 +8323,7 @@ cp_complete_array_type (tree *ptype, tree initial_value, 
bool do_default)
      bits.  See also complete_type which does the same thing for arrays
      of fixed size.  */
   type = *ptype;
-  if (TYPE_DOMAIN (type))
+  if (type != error_mark_node && TYPE_DOMAIN (type))
     {
       elt_type = TREE_TYPE (type);
       TYPE_NEEDS_CONSTRUCTING (type) = TYPE_NEEDS_CONSTRUCTING (elt_type);
diff --git gcc/testsuite/g++.dg/parse/array-size3.C 
gcc/testsuite/g++.dg/parse/array-size3.C
index e69de29bb2d..c3a824a91d7 100644
--- gcc/testsuite/g++.dg/parse/array-size3.C
+++ gcc/testsuite/g++.dg/parse/array-size3.C
@@ -0,0 +1,7 @@
+// PR c++/84663
+
+struct S {
+  typedef S T[8];
+  int f : -1ULL; // { dg-warning "exceeds its type" }
+  S () { struct { T d; } e[]; } // { dg-error "size" }
+};

        Marek

Reply via email to