diff options
author | Jason Merrill <jason@redhat.com> | 2014-03-04 17:16:12 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-03-04 17:16:12 -0500 |
commit | ca982b1c62cb8ee2d19cd3c44f849f0ec7be4c12 (patch) | |
tree | 33f9f90f783ea5acd5f0f886c186080da789ae42 /gcc | |
parent | 201fe4c608fea87610940f2e6329f2ae13157cee (diff) | |
download | gcc-ca982b1c62cb8ee2d19cd3c44f849f0ec7be4c12.zip gcc-ca982b1c62cb8ee2d19cd3c44f849f0ec7be4c12.tar.gz gcc-ca982b1c62cb8ee2d19cd3c44f849f0ec7be4c12.tar.bz2 |
re PR c++/60417 ([DR 1518] Bogus error on C++03 aggregate initialization)
PR c++/60417
* typeck2.c (process_init_constructor_record): Set
CONSTRUCTOR_IS_DIRECT_INIT on {} for omitted initializers.
From-SVN: r208333
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/explicit1.C | 9 |
3 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2ad6b7a..6f2b38a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-03-04 Jason Merrill <jason@redhat.com> + PR c++/60417 + * typeck2.c (process_init_constructor_record): Set + CONSTRUCTOR_IS_DIRECT_INIT on {} for omitted initializers. + PR c++/60415 PR c++/54359 * parser.c (cp_parser_direct_declarator): Set declarator to diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 8877286..3a4caa0 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1312,6 +1312,9 @@ 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. */ next = build_constructor (init_list_type_node, NULL); + /* Call this direct-initialization pending DR 1518 resolution so + that explicit default ctors don't break valid C++03 code. */ + CONSTRUCTOR_IS_DIRECT_INIT (next) = true; next = massage_init_elt (TREE_TYPE (field), next, complain); /* Warn when some struct elements are implicitly initialized. */ diff --git a/gcc/testsuite/g++.dg/init/explicit1.C b/gcc/testsuite/g++.dg/init/explicit1.C new file mode 100644 index 0000000..f376df2 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/explicit1.C @@ -0,0 +1,9 @@ +// PR c++/60417 + +struct A { explicit A(int = 0); }; +struct B { A a; }; + +int main() +{ + B b = {}; +} |