diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-08-06 16:25:19 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-08-06 16:25:19 +0000 |
commit | d748d5cd08b9a7d6099b640dcb43e8dd91608f89 (patch) | |
tree | 145a67ca32f7630b9856f54b551b05a96ef421c1 /gcc | |
parent | 94966ac4a4c6c19a795595f586942e7e45747171 (diff) | |
download | gcc-d748d5cd08b9a7d6099b640dcb43e8dd91608f89.tar.gz |
PR c++/40948
* init.c (build_vec_init): Evaluate the initializer before
starting the initialization try block.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150529 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/complit12.C | 11 |
4 files changed, 36 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e86ab38763..a7cc6b15d80 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-08-05 Jason Merrill <jason@redhat.com> + + PR c++/40948 + * init.c (build_vec_init): Evaluate the initializer before + starting the initialization try block. + 2009-08-05 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c++/36069 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 4462428321b..ef18a6c1041 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2698,7 +2698,8 @@ build_vec_init (tree base, tree maxindex, tree init, /* Look through the TARGET_EXPR around a compound literal. */ if (init && TREE_CODE (init) == TARGET_EXPR - && TREE_CODE (TARGET_EXPR_INITIAL (init)) == CONSTRUCTOR) + && TREE_CODE (TARGET_EXPR_INITIAL (init)) == CONSTRUCTOR + && from_array != 2) init = TARGET_EXPR_INITIAL (init); if (init @@ -2769,6 +2770,17 @@ build_vec_init (tree base, tree maxindex, tree init, base = get_temp_regvar (ptype, rval); iterator = get_temp_regvar (ptrdiff_type_node, maxindex); + /* If initializing one array from another, initialize element by + element. We rely upon the below calls to do the argument + checking. Evaluate the initializer before entering the try block. */ + if (from_array && init && TREE_CODE (init) != CONSTRUCTOR) + { + base2 = decay_conversion (init); + itype = TREE_TYPE (base2); + base2 = get_temp_regvar (itype, base2); + itype = TREE_TYPE (itype); + } + /* Protect the entire array initialization so that we can destroy the partially constructed array if an exception is thrown. But don't do this if we're assigning. */ @@ -2811,16 +2823,8 @@ build_vec_init (tree base, tree maxindex, tree init, } else if (from_array) { - /* If initializing one array from another, initialize element by - element. We rely upon the below calls the do argument - checking. */ if (init) - { - base2 = decay_conversion (init); - itype = TREE_TYPE (base2); - base2 = get_temp_regvar (itype, base2); - itype = TREE_TYPE (itype); - } + /* OK, we set base2 above. */; else if (TYPE_LANG_SPECIFIC (type) && TYPE_NEEDS_CONSTRUCTING (type) && ! TYPE_HAS_DEFAULT_CONSTRUCTOR (type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 98392a5157c..b17d3484fdd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-08-05 Jason Merrill <jason@redhat.com> + + PR c++/40948 + * g++.dg/ext/complit12.C: Expand. + 2009-08-05 Richard Earnshaw <rearnsha@arm.com> Merge ARM/hard_vfp_branch to trunk. diff --git a/gcc/testsuite/g++.dg/ext/complit12.C b/gcc/testsuite/g++.dg/ext/complit12.C index 81056214483..29c9af1864f 100644 --- a/gcc/testsuite/g++.dg/ext/complit12.C +++ b/gcc/testsuite/g++.dg/ext/complit12.C @@ -30,6 +30,11 @@ T::T () : m ((M[4]) { M (), M (), M (), M () }) { } +typedef M MA[1]; +MA &bar (MA, MA& r) { return r; } + +M f(M m) { return m; } + int main () { { @@ -48,6 +53,12 @@ int main () T t; if (c != 11) return 5; + MA ma = bar ((M[2]) { M(), M() }, m); + if (c != 12) + return 7; + M mm[2] = ((M[2]) { f(M()), f(M()) }); + if (c != 14) + return 8; } if (c != 0) return 6; |