diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-10 10:23:54 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-10 10:23:54 -0400 |
commit | 05c602a135224b1fbc573fc54e3c925196503187 (patch) | |
tree | 11c92ee0d3e55761dbb1e049267218a19952667d | |
parent | 4b51265982bb3817d60989ebdf4cbd2f8809902d (diff) | |
download | gcc-05c602a135224b1fbc573fc54e3c925196503187.zip gcc-05c602a135224b1fbc573fc54e3c925196503187.tar.gz gcc-05c602a135224b1fbc573fc54e3c925196503187.tar.bz2 |
PR c++/85285 - ICE with flexible array after substitution.
* pt.c (instantiate_class_template_1): Check for flexible array in
union.
From-SVN: r259277
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary30.C | 8 |
3 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 33f0c37..4359250 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-10 Jason Merrill <jason@redhat.com> + + PR c++/85285 - ICE with flexible array after substitution. + * pt.c (instantiate_class_template_1): Check for flexible array in + union. + 2018-04-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/85227 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index db3d7e3..76e546c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10904,6 +10904,14 @@ instantiate_class_template_1 (tree type) cxx_incomplete_type_error (r, rtype); TREE_TYPE (r) = error_mark_node; } + else if (TREE_CODE (rtype) == ARRAY_TYPE + && TYPE_DOMAIN (rtype) == NULL_TREE + && (TREE_CODE (type) == UNION_TYPE + || TREE_CODE (type) == QUAL_UNION_TYPE)) + { + error ("flexible array member %qD in union", r); + TREE_TYPE (r) = error_mark_node; + } } /* If it is a TYPE_DECL for a class-scoped ENUMERAL_TYPE, diff --git a/gcc/testsuite/g++.dg/ext/flexary30.C b/gcc/testsuite/g++.dg/ext/flexary30.C new file mode 100644 index 0000000..59b7587 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary30.C @@ -0,0 +1,8 @@ +// PR c++/85285 + +template<typename T> union A +{ + T x; // { dg-error "flexible array" } +}; + +A<int[]> a; |