diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2015-07-10 22:56:35 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-07-10 22:56:35 +0000 |
commit | 0a73242e1ab3ac00d8fe9a98f10732473a96dc04 (patch) | |
tree | 538ca2171bc2df49606b4e053788104ca7fc3cb4 /gcc | |
parent | 2ec7e902e7dfa2901bdba3765e11c3bcdec543f2 (diff) | |
download | gcc-0a73242e1ab3ac00d8fe9a98f10732473a96dc04.zip gcc-0a73242e1ab3ac00d8fe9a98f10732473a96dc04.tar.gz gcc-0a73242e1ab3ac00d8fe9a98f10732473a96dc04.tar.bz2 |
re PR c++/54521 (g++ fails to call explicit constructors in the second step of copy initialization)
/cp
2015-07-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54521
* call.c (convert_like_real): Do not set LOOKUP_ONLYCONVERTING for
the second step of copy-initialization.
/testsuite
2015-07-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54521
* g++.dg/init/explicit3.C: New.
From-SVN: r225705
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/explicit3.C | 12 |
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 130e358..9d9e0c1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-07-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54521 + * call.c (convert_like_real): Do not set LOOKUP_ONLYCONVERTING for + the second step of copy-initialization. + 2015-07-10 Jason Merrill <jason@redhat.com> * pt.c (find_parameter_packs_r): Handle variable templates. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4da1072..07d6f0e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6437,12 +6437,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, /* Copy-initialization where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of the destination [is treated as direct-initialization]. [dcl.init] */ - flags = LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING; + flags = LOOKUP_NORMAL; if (convs->user_conv_p) /* This conversion is being done in the context of a user-defined conversion (i.e. the second step of copy-initialization), so don't allow any more. */ flags |= LOOKUP_NO_CONVERSION; + else + flags |= LOOKUP_ONLYCONVERTING; if (convs->rvaluedness_matches_p) flags |= LOOKUP_PREFER_RVALUE; if (TREE_CODE (expr) == TARGET_EXPR diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 44d391b..dde2803 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54521 + * g++.dg/init/explicit3.C: New. + 2015-07-10 H.J. Lu <hongjiu.lu@intel.com> PR target/66819 diff --git a/gcc/testsuite/g++.dg/init/explicit3.C b/gcc/testsuite/g++.dg/init/explicit3.C new file mode 100644 index 0000000..c5d4e0d --- /dev/null +++ b/gcc/testsuite/g++.dg/init/explicit3.C @@ -0,0 +1,12 @@ +// PR c++/54521 + +struct X +{ + X(int) {} + explicit X(X const &) {} +}; + +int main() +{ + X x = 1; +} |