This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/84663, ICE with incomplete array
- From: Marek Polacek <polacek at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Mar 2018 18:38:46 +0100
- Subject: C++ PATCH for c++/84663, ICE with incomplete array
- Authentication-results: sourceware.org; auth=none
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 <polacek@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