diff options
author | Jason Merrill <jason@redhat.com> | 2011-01-14 08:08:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-01-14 08:08:02 -0500 |
commit | 70f961a51eed84328a6c2226d4a72f90801ca3b5 (patch) | |
tree | 0ccd3b413969c837c4e57539fdf78029b0c0ba41 | |
parent | 8f66db3b32436cd7902dc553cc013dddf5b26b79 (diff) | |
download | gcc-70f961a51eed84328a6c2226d4a72f90801ca3b5.zip gcc-70f961a51eed84328a6c2226d4a72f90801ca3b5.tar.gz gcc-70f961a51eed84328a6c2226d4a72f90801ca3b5.tar.bz2 |
re PR c++/46688 (g++ requires a function declaration when it should not)
PR c++/46688
* tree.c (build_vec_init_expr): Handle flexible array
properly.
From-SVN: r168782
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/tree.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary2.C | 11 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a57f978..d841686 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-01-14 Jason Merrill <jason@redhat.com> + + PR c++/46688 + * tree.c (build_vec_init_expr): Handle flexible array + properly. + 2011-01-13 Kai Tietz <kai.tietz@onevision.com> PR c++/47213 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 213279a..813b88d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -474,7 +474,12 @@ build_vec_init_expr (tree type, tree init) what functions are needed. Here we assume that init is either NULL_TREE, void_type_node (indicating value-initialization), or another array to copy. */ - if (init == void_type_node) + if (integer_zerop (array_type_nelts_total (type))) + { + /* No actual initialization to do. */; + init = NULL_TREE; + } + else if (init == void_type_node) { elt_init = build_value_init (inner_type, tf_warning_or_error); value_init = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c67c37c..9851be4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-01-14 Jason Merrill <jason@redhat.com> + + * g++.dg/ext/flexary2.C: New. + 2011-01-14 Richard Guenther <rguenther@suse.de> PR middle-end/47281 diff --git a/gcc/testsuite/g++.dg/ext/flexary2.C b/gcc/testsuite/g++.dg/ext/flexary2.C new file mode 100644 index 0000000..4855b3f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary2.C @@ -0,0 +1,11 @@ +// PR c++/46688 +// { dg-options "" } + +struct A { + A(int); +}; + +struct B { + B() {} + A a[]; +}; |