re PR c++/54521 (g++ fails to call explicit constructors in the second step of copy...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 10 Jul 2015 22:56:35 +0000 (22:56 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 10 Jul 2015 22:56:35 +0000 (22:56 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/explicit3.C [new file with mode: 0644]

index 130e35863fcaffb26caaca5622ad21bc0e118556..9d9e0c145c69f4f84eb28717d3846bf0af0ae538 100644 (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.
index 4da1072bf3db94ccf2bee17031b334d1bac33f39..07d6f0e00eaac83c609acb36bd49c41c69c46a89 100644 (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
index 44d391b8ba104f66c91c1a74a6bfea390c63f7a0..dde2803688eb428b453716951c3e0985ad7f2109 100644 (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
diff --git a/gcc/testsuite/g++.dg/init/explicit3.C b/gcc/testsuite/g++.dg/init/explicit3.C
new file mode 100644 (file)
index 0000000..c5d4e0d
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/54521
+
+struct X
+{
+  X(int) {}
+  explicit X(X const &) {}
+};
+
+int main()
+{
+  X x = 1;
+}