]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/50523 (C++ FE apparently incorrectly rejects tramp3d)
authorJason Merrill <jason@redhat.com>
Mon, 26 Sep 2011 15:47:17 +0000 (11:47 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Sep 2011 15:47:17 +0000 (11:47 -0400)
PR c++/50523
* call.c (implicit_conversion): Mask out inappropriate LOOKUP
flags at the top of the function.

From-SVN: r179203

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/ref-conv2.C [new file with mode: 0644]

index 59b162df7f99923b2831dcd90f6b314e08558b06..865d76461e16bd620eb8c00af281c45a3fd1adea 100644 (file)
@@ -1,5 +1,9 @@
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50523
+       * call.c (implicit_conversion): Mask out inappropriate LOOKUP
+       flags at the top of the function.
+
        * pt.c (tsubst_copy) [PARM_DECL]: Handle 'this' in NSDMI.
 
 2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>
index 6a7dfd398741b19c2ed626e4acf3838b23c21461..579e563ea1c68ff188de0f1604f47fe16f2c0c8e 100644 (file)
@@ -1660,6 +1660,12 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
       || expr == error_mark_node)
     return NULL;
 
+  /* Other flags only apply to the primary function in overload
+     resolution, or after we've chosen one.  */
+  flags &= (LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION|LOOKUP_COPY_PARM
+           |LOOKUP_NO_TEMP_BIND|LOOKUP_NO_RVAL_BIND|LOOKUP_PREFER_RVALUE
+           |LOOKUP_NO_NARROWING|LOOKUP_PROTECT);
+
   if (TREE_CODE (to) == REFERENCE_TYPE)
     conv = reference_binding (to, from, expr, c_cast_p, flags);
   else
@@ -1716,15 +1722,13 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
       && (flags & LOOKUP_NO_CONVERSION) == 0)
     {
       struct z_candidate *cand;
-      int convflags = (flags & (LOOKUP_NO_TEMP_BIND|LOOKUP_ONLYCONVERTING
-                               |LOOKUP_NO_NARROWING));
 
       if (CLASS_TYPE_P (to)
          && BRACE_ENCLOSED_INITIALIZER_P (expr)
          && !CLASSTYPE_NON_AGGREGATE (complete_type (to)))
        return build_aggr_conv (to, expr, flags);
 
-      cand = build_user_type_conversion_1 (to, expr, convflags);
+      cand = build_user_type_conversion_1 (to, expr, flags);
       if (cand)
        conv = cand->second_conv;
 
index e0250194a9037ae51c379cd61294e780e783ca5f..500fbf577ee677e220c1cbec8c08d1d3e2169c6e 100644 (file)
@@ -1,5 +1,8 @@
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50523
+       * g++.dg/overload/ref-conv2.C: New.
+
        * g++.dg/cpp0x/nsdmi-template1.C: New.
 
 2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>
diff --git a/gcc/testsuite/g++.dg/overload/ref-conv2.C b/gcc/testsuite/g++.dg/overload/ref-conv2.C
new file mode 100644 (file)
index 0000000..bb0ad39
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/50523
+
+template <class T>
+struct A
+{
+  A(const T&);
+  operator T&() const;
+  operator const T&() const;
+};
+
+int main()
+{
+  A<int> a(1);
+  A<int> a2(a);
+}