diff options
author | Jason Merrill <jason@redhat.com> | 2014-02-21 09:56:53 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-02-21 09:56:53 -0500 |
commit | 843633f841be49bf6d15a2f6208ce384870f37b8 (patch) | |
tree | ed6c2cbc9b08dfc6ace3e8a097c37fab33f79ba1 | |
parent | cd3ef6f762a6dc3d7871f33b297be5b684b68ad0 (diff) | |
download | gcc-843633f841be49bf6d15a2f6208ce384870f37b8.zip gcc-843633f841be49bf6d15a2f6208ce384870f37b8.tar.gz gcc-843633f841be49bf6d15a2f6208ce384870f37b8.tar.bz2 |
re PR c++/60224 (ICE using invalid initializer for array)
PR c++/60224
* decl.c (cp_complete_array_type, maybe_deduce_size_from_array_init):
Don't get confused by a CONSTRUCTOR that already has a type.
From-SVN: r208002
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/array36.C | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 61f5859..62aacd6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-02-21 Jason Merrill <jason@redhat.com> + PR c++/60224 + * decl.c (cp_complete_array_type, maybe_deduce_size_from_array_init): + Don't get confused by a CONSTRUCTOR that already has a type. + PR c++/60277 * call.c (build_array_conv): Don't crash on VLA. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b7d2d9f..04c4cf5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4880,7 +4880,7 @@ maybe_deduce_size_from_array_init (tree decl, tree init) those are not supported in GNU C++, and as the middle-end will crash if presented with a non-numeric designated initializer. */ - if (initializer && TREE_CODE (initializer) == CONSTRUCTOR) + if (initializer && BRACE_ENCLOSED_INITIALIZER_P (initializer)) { vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initializer); constructor_elt *ce; @@ -7099,6 +7099,11 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default) int failure; tree type, elt_type; + /* Don't get confused by a CONSTRUCTOR for some other type. */ + if (initial_value && TREE_CODE (initial_value) == CONSTRUCTOR + && !BRACE_ENCLOSED_INITIALIZER_P (initial_value)) + return 1; + if (initial_value) { unsigned HOST_WIDE_INT i; diff --git a/gcc/testsuite/g++.dg/init/array36.C b/gcc/testsuite/g++.dg/init/array36.C new file mode 100644 index 0000000..77e4f90 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array36.C @@ -0,0 +1,8 @@ +// PR c++/60224 + +struct A {}; + +void foo() +{ + bool b[] = (int (A::*)())0; // { dg-error "" } +} |