aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-05-02 17:59:49 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-05-02 17:59:49 -0400
commit0a2cdfe6fdd3376e694a83b3229fa03d018dbfda (patch)
tree8f138e2152d3982b025b18f53bee0ac5741bd35d /gcc
parent2609a0ce534be7a39dce4dee437eab54503e9b5e (diff)
downloadgcc-0a2cdfe6fdd3376e694a83b3229fa03d018dbfda.zip
gcc-0a2cdfe6fdd3376e694a83b3229fa03d018dbfda.tar.gz
gcc-0a2cdfe6fdd3376e694a83b3229fa03d018dbfda.tar.bz2
re PR c++/48834 (-fno-exceptions causes wrong code generation on C++ code)
PR c++/48834 * tree.c (build_vec_init_expr): Set TREE_SIDE_EFFECTS. Protect an explicit target. From-SVN: r173272
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/tree.c7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/init/new31.C18
4 files changed, 32 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 983939e..127d77a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-05-02 Jason Merrill <jason@redhat.com>
+ PR c++/48834
+ * tree.c (build_vec_init_expr): Set TREE_SIDE_EFFECTS.
+ Protect an explicit target.
+
PR c++/48446
* decl.c (stabilize_save_expr_r, stabilize_vla_size): New.
(compute_array_index_type): Revert earlier 48446 changes.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 2eaa1db..fff3fbf 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -564,6 +564,7 @@ build_vec_init_expr (tree target, tree init, tree nelts,
elt_init = build_vec_init_elt (type, init, complain);
init = build3 (VEC_INIT_EXPR, type, slot, init, nelts);
+ TREE_SIDE_EFFECTS (init) = true;
SET_EXPR_LOCATION (init, input_location);
if (cxx_dialect >= cxx0x
@@ -571,7 +572,11 @@ build_vec_init_expr (tree target, tree init, tree nelts,
VEC_INIT_EXPR_IS_CONSTEXPR (init) = true;
VEC_INIT_EXPR_VALUE_INIT (init) = value_init;
- if (slot != target)
+ if (slot == target)
+ /* If we specified what array we're initializing, make sure
+ we don't override that in cp_gimplify_init_expr. */
+ init = cp_build_compound_expr (init, slot, complain);
+ else
{
init = build_target_expr (slot, init, complain);
TARGET_EXPR_IMPLICIT_P (init) = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index be4f4b6..216beee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-02 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/init/new31.C: New.
+
2011-05-02 Simon Martin <simartin@users.sourceforge.net>
PR c/35445
diff --git a/gcc/testsuite/g++.dg/init/new31.C b/gcc/testsuite/g++.dg/init/new31.C
new file mode 100644
index 0000000..33c94aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/new31.C
@@ -0,0 +1,18 @@
+// PR c++/48834
+// { dg-options -Wuninitialized }
+// { dg-do run }
+
+struct S
+{
+ S ():i (0)
+ {
+ }
+ int i;
+};
+
+int
+main ()
+{
+ S *s = new S[2];
+ return 0;
+}