aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2010-04-07 15:11:42 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2010-04-07 17:11:42 +0200
commit7c094c11510e9a7bb99a9b2b2dd4f6087cedda3c (patch)
treeadf46843d8ba5e7d764fe540bc2791c6e1310564 /gcc
parent95d938ee6f8d45d9e51c05bea7cb1b7dd695bbf4 (diff)
downloadgcc-7c094c11510e9a7bb99a9b2b2dd4f6087cedda3c.zip
gcc-7c094c11510e9a7bb99a9b2b2dd4f6087cedda3c.tar.gz
gcc-7c094c11510e9a7bb99a9b2b2dd4f6087cedda3c.tar.bz2
re PR c++/40239 (Aggregate initialization requires copy constructor)
Fix PR c++/40239 gcc/cp/ChangeLog: PR c++/40239 * typeck2.c (process_init_constructor_record): value-initialize members that are are not explicitely initialized. gcc/testsuite/ChangeLog: PR c++/40239 * g++.dg/init/aggr5.C: New test. * g++.dg/init/aggr5.C: New test. From-SVN: r158066
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck2.c10
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/init/aggr5.C11
-rw-r--r--gcc/testsuite/g++.dg/init/aggr6.C11
5 files changed, 43 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fd10691..6af8a20 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-07 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/40239
+ * typeck2.c (process_init_constructor_record):
+ value-initialize members that are are not explicitely
+ initialized.
+
2010-04-07 Jie Zhang <jie@codesourcery.com>
PR c++/42556
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 2610b28..444ba73 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1166,8 +1166,14 @@ process_init_constructor_record (tree type, tree init)
for us, so build up TARGET_EXPRs. If the type in question is
a class, just build one up; if it's an array, recurse. */
if (MAYBE_CLASS_TYPE_P (TREE_TYPE (field)))
- next = build_functional_cast (TREE_TYPE (field), NULL_TREE,
- tf_warning_or_error);
+ {
+ next = build_functional_cast (TREE_TYPE (field), NULL_TREE,
+ tf_warning_or_error);
+ /* direct-initialize the target. No temporary is going
+ to be involved. */
+ if (TREE_CODE (next) == TARGET_EXPR)
+ TARGET_EXPR_DIRECT_INIT_P (next) = true;
+ }
else
next = build_constructor (init_list_type_node, NULL);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a2faaf5..65c9f02 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-07 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/40239
+ * g++.dg/init/aggr5.C: New test.
+ * g++.dg/init/aggr5.C: New test.
+
2010-04-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43270
diff --git a/gcc/testsuite/g++.dg/init/aggr5.C b/gcc/testsuite/g++.dg/init/aggr5.C
new file mode 100644
index 0000000..2284595
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/aggr5.C
@@ -0,0 +1,11 @@
+// Origin PR c++/40239
+// { dg-do "compile" }
+
+struct B { B() { } private: B(B const&); };
+struct A { int a; B b; };
+
+int
+main()
+{
+ A a = {0};
+}
diff --git a/gcc/testsuite/g++.dg/init/aggr6.C b/gcc/testsuite/g++.dg/init/aggr6.C
new file mode 100644
index 0000000..98628d2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/aggr6.C
@@ -0,0 +1,11 @@
+// Origin PR c++/40239
+// { dg-do compile }
+
+struct B { B() { } private: B(B const&); };
+struct A { int a; B b; };
+
+int
+main()
+{
+ A a = {};
+}