diff options
author | Jason Merrill <jason@redhat.com> | 2010-06-15 15:59:02 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-06-15 15:59:02 -0400 |
commit | 5c77749e30496db4cb726ead698210a486d95b79 (patch) | |
tree | 5b05e71c250fbb3fbbe429253ef06ff1e151da29 | |
parent | 0ba8746d0a20a0f08a57435d90af3ab91e99c621 (diff) | |
download | gcc-5c77749e30496db4cb726ead698210a486d95b79.zip gcc-5c77749e30496db4cb726ead698210a486d95b79.tar.gz gcc-5c77749e30496db4cb726ead698210a486d95b79.tar.bz2 |
call.c (convert_like_real): Don't complain about list-value-initialization from an explicit constructor.
* call.c (convert_like_real): Don't complain about
list-value-initialization from an explicit constructor.
From-SVN: r160807
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/call.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist40.C | 12 |
4 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ce7d085..c82db7e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2010-06-15 Jason Merrill <jason@redhat.com> + * call.c (convert_like_real): Don't complain about + list-value-initialization from an explicit constructor. + * decl.c (duplicate_decls): Use DECL_IS_BUILTIN rather than test DECL_SOURCE_LOCATION directly. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 9ce1c53..60d7333 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4956,7 +4956,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, /* When converting from an init list we consider explicit constructors, but actually trying to call one is an error. */ - if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)) + if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn) + /* Unless we're calling it for value-initialization from an + empty list, since that is handled separately in 8.5.4. */ + && cand->num_convs > 0) { if (complain & tf_error) error ("converting to %qT from initializer list would use " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 910dcc1..e6ce32a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2010-06-15 Jason Merrill <jason@redhat.com> + * g++.dg/cpp0x/initlist40.C: New. + * g++.dg/cpp0x/initlist39.C: New. 2010-06-15 Sebastian Pop <sebastian.pop@amd.com> diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist40.C b/gcc/testsuite/g++.dg/cpp0x/initlist40.C new file mode 100644 index 0000000..f270360 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist40.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++0x" } + +struct A +{ + explicit A(int = 42); +}; + +int main() +{ + A a1 = { }; + A a2 = { 24 }; // { dg-error "explicit" } +} |