diff options
author | Jason Merrill <jason@redhat.com> | 2010-05-24 14:38:16 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-05-24 14:38:16 -0400 |
commit | 611d6f76fe8eae737566fb809f61b0c094ef92c9 (patch) | |
tree | 538a9f415da25d0233304dc40b74faf54a537d08 /gcc | |
parent | e20463aaf048d91eee354cc784819d1988abd2c2 (diff) | |
download | gcc-611d6f76fe8eae737566fb809f61b0c094ef92c9.zip gcc-611d6f76fe8eae737566fb809f61b0c094ef92c9.tar.gz gcc-611d6f76fe8eae737566fb809f61b0c094ef92c9.tar.bz2 |
re PR c++/41510 ([C++0x] std::complex vs. initialization lists)
PR c++/41510
* decl.c (check_initializer): Don't wrap an init-list in a
TREE_LIST.
* init.c (build_aggr_init): Don't assume copy-initialization if
init has CONSTRUCTOR_IS_DIRECT_INIT.
* call.c (build_new_method_call): Sanity check.
From-SVN: r159792
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 1 | ||||
-rw-r--r-- | gcc/cp/init.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist35.C | 24 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/brace6.C | 4 |
7 files changed, 46 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b0454e6..2a3a8a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2010-05-24 Jason Merrill <jason@redhat.com> + + PR c++/41510 + * decl.c (check_initializer): Don't wrap an init-list in a + TREE_LIST. + * init.c (build_aggr_init): Don't assume copy-initialization if + init has CONSTRUCTOR_IS_DIRECT_INIT. + * call.c (build_new_method_call): Sanity check. + 2010-05-24 Nathan Froyd <froydnj@codesourcery.com> * rtti.c (tinfo_base_init): Use build_constructor instead of diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 3cb30a5..890ab88 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6350,7 +6350,8 @@ build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args, && BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *args, 0)) && CONSTRUCTOR_IS_DIRECT_INIT (VEC_index (tree, *args, 0))) { - gcc_assert (VEC_length (tree, *args) == 1); + gcc_assert (VEC_length (tree, *args) == 1 + && !(flags & LOOKUP_ONLYCONVERTING)); list = VEC_index (tree, *args, 0); if (TYPE_HAS_LIST_CTOR (basetype)) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 95ae8eb..5420f71 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5278,7 +5278,6 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) error ("in C++98 %qD must be initialized by constructor, " "not by %<{...}%>", decl); - init = build_tree_list (NULL_TREE, init); } else if (TREE_CODE (type) == VECTOR_TYPE && TYPE_VECTOR_OPAQUE (type)) { diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1fb5eb0..bf80c09 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1240,7 +1240,9 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_READONLY (exp) = 0; TREE_THIS_VOLATILE (exp) = 0; - if (init && TREE_CODE (init) != TREE_LIST) + if (init && TREE_CODE (init) != TREE_LIST + && !(BRACE_ENCLOSED_INITIALIZER_P (init) + && CONSTRUCTOR_IS_DIRECT_INIT (init))) flags |= LOOKUP_ONLYCONVERTING; if (TREE_CODE (type) == ARRAY_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0b34c9..eb1361d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-05-24 Jason Merrill <jason@redhat.com> + + PR c++/41510 + * g++.dg/cpp0x/initlist35.C: New. + * g++.dg/init/brace6.C: Adjust. + 2010-05-24 Paul Brook <paul@codesourcery.com> * gcc.target/arm/frame-pointer-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist35.C b/gcc/testsuite/g++.dg/cpp0x/initlist35.C new file mode 100644 index 0000000..e5b7cb4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist35.C @@ -0,0 +1,24 @@ +// PR c++/41510 +// { dg-options "-std=c++0x" } + +struct B +{ + B(int, int); +}; +struct A +{ + A(int, int); + A(const B&); +}; + +void f() +{ + A a = { 1, 2 }; +}; + +template <class T> void g() +{ + A a = { 1, 2 }; +}; + +template void g<int>(); diff --git a/gcc/testsuite/g++.dg/init/brace6.C b/gcc/testsuite/g++.dg/init/brace6.C index bff89da..96b35b0 100644 --- a/gcc/testsuite/g++.dg/init/brace6.C +++ b/gcc/testsuite/g++.dg/init/brace6.C @@ -6,7 +6,7 @@ struct A { }; struct B { - B(const B&); // { dg-message "candidate" } + B(const B&); int b; }; @@ -19,7 +19,7 @@ int main() int i = { 1 }; int j = { 1, 2 }; /* { dg-error "requires one element" } */ A a = { 6 }; /* { dg-error "initialize" } */ - B b = { 6 }; /* { dg-error "initialize" } */ + B b = { 6 }; /* { dg-error "" } */ C c = { 6 }; /* { dg-error "too many initializers" } */ D d = { 6 }; } |