aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-10-25 14:24:19 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-10-25 14:24:19 -0400
commit0c59fd2fd22fa78fa357d6f509ac5e9be17316c1 (patch)
tree751941f79c832e8ddd5ea2e1897c54bef7654a0a
parent04cc7d7c136f99982541145e155c8281dc57dc1b (diff)
downloadgcc-0c59fd2fd22fa78fa357d6f509ac5e9be17316c1.zip
gcc-0c59fd2fd22fa78fa357d6f509ac5e9be17316c1.tar.gz
gcc-0c59fd2fd22fa78fa357d6f509ac5e9be17316c1.tar.bz2
re PR c++/49996 (Internal error in verify_gimple_stmt: initializing struct in new-initializer)
PR c++/49996 * tree.c (stabilize_init): Stabilize scalar elements of a CONSTRUCTOR, too. From-SVN: r180441
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/tree.c17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist59.C18
4 files changed, 42 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 58c00de..0586fe1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-25 Jason Merrill <jason@redhat.com>
+
+ PR c++/49996
+ * tree.c (stabilize_init): Stabilize scalar elements of a
+ CONSTRUCTOR, too.
+
2011-10-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50858
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index d023eb8..707f2c8 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3345,11 +3345,20 @@ stabilize_init (tree init, tree *initp)
/* Aggregate initialization: stabilize each of the field
initializers. */
unsigned i;
- tree value;
+ constructor_elt *ce;
bool good = true;
- FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), i, value)
- if (!stabilize_init (value, initp))
- good = false;
+ VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (t);
+ for (i = 0; VEC_iterate (constructor_elt, v, i, ce); ++i)
+ {
+ tree type = TREE_TYPE (ce->value);
+ tree subinit;
+ if (TREE_CODE (type) == REFERENCE_TYPE
+ || SCALAR_TYPE_P (type))
+ ce->value = stabilize_expr (ce->value, &subinit);
+ else if (!stabilize_init (ce->value, &subinit))
+ good = false;
+ *initp = add_stmt_to_compound (*initp, subinit);
+ }
return good;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 40e1de1..7a82af0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-10-25 Jason Merrill <jason@redhat.com>
+
+ PR c++/49996
+ * g++.dg/cpp0x/initlist59.C: New.
+
2011-10-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50858
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist59.C b/gcc/testsuite/g++.dg/cpp0x/initlist59.C
new file mode 100644
index 0000000..2cc015d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist59.C
@@ -0,0 +1,18 @@
+// PR c++/49996
+// { dg-options -std=c++0x }
+
+struct A
+{
+ ~A()
+ { }
+};
+
+struct B
+{
+ const A& ref;
+};
+
+int main()
+{
+ B* p = new B{A()};
+}