diff options
author | Jason Merrill <jason@redhat.com> | 2009-08-04 02:26:34 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2009-08-04 02:26:34 +0000 |
commit | 4ed34240b9ee4be3984151a14779f85f207c263c (patch) | |
tree | 4294af85b3367e6a88a01be14afe5d03c8353fbe | |
parent | 8f4c2cdf714d90bd626bb52763d483ad4add1021 (diff) |
PR c++/40948
* init.c (build_vec_init): Look through a TARGET_EXPR around a
CONSTRUCTOR.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch@150395 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/init.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/complit12.C | 54 |
4 files changed, 73 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fbe0f2ba647..decc99af37d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-08-03 Jason Merrill <jason@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + PR c++/40948 + * init.c (build_vec_init): Look through a TARGET_EXPR around a + CONSTRUCTOR. + 2009-07-26 Simon Martin <simartin@users.sourceforge.net> PR c++/40749 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 0632cb0c1a3..28217f8b3dc 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2695,6 +2695,12 @@ build_vec_init (tree base, tree maxindex, tree init, gcc_assert (!init); inner_elt_type = strip_array_types (type); + + /* Look through the TARGET_EXPR around a compound literal. */ + if (init && TREE_CODE (init) == TARGET_EXPR + && TREE_CODE (TARGET_EXPR_INITIAL (init)) == CONSTRUCTOR) + init = TARGET_EXPR_INITIAL (init); + if (init && TREE_CODE (atype) == ARRAY_TYPE && (from_array == 2 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 40c8105801a..d3590cecb75 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-08-03 Jason Merrill <jason@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + PR c++/40948 + * g++.dg/ext/complit12.C: New. + 2009-08-03 Janis Johnson <janis187@us.ibm.com> PR c/39902 diff --git a/gcc/testsuite/g++.dg/ext/complit12.C b/gcc/testsuite/g++.dg/ext/complit12.C new file mode 100644 index 00000000000..81056214483 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/complit12.C @@ -0,0 +1,54 @@ +// PR c++/40948 +// { dg-do run } +// { dg-options "" } + +int c; +struct M +{ + M () { ++c; } + M (const M&) { ++c; } + ~M () { --c; } +}; + +struct S +{ + S (); + M m[1]; +}; + +S::S () : m ((M[1]) { M () }) +{ +} + +struct T +{ + T (); + M m[4]; +}; + +T::T () : m ((M[4]) { M (), M (), M (), M () }) +{ +} + +int main () +{ + { + M m[1] = (M[1]) { M () }; + if (c != 1) + return 1; + M n = (M) { M () }; + if (c != 2) + return 2; + M o[4] = (M[4]) { M (), M (), M (), M () }; + if (c != 6) + return 3; + S s; + if (c != 7) + return 4; + T t; + if (c != 11) + return 5; + } + if (c != 0) + return 6; +} |