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
This commit is contained in:
Paolo Carlini 2015-07-10 22:56:35 +00:00 committed by Paolo Carlini
parent 2ec7e902e7
commit 0a73242e1a
4 changed files with 26 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,12 @@
// PR c++/54521
struct X
{
X(int) {}
explicit X(X const &) {}
};
int main()
{
X x = 1;
}