[cfe-commits] r101132 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp

Douglas Gregor dgregor at apple.com
Tue Apr 13 08:07:46 PDT 2010


Author: dgregor
Date: Tue Apr 13 10:07:45 2010
New Revision: 101132

URL: http://llvm.org/viewvc/llvm-project?rev=101132&view=rev
Log:
During referencing binding, only consider conversion functions for
direct reference binding when the source and target types are not
reference-related. Fixes PR6066.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=101132&r1=101131&r2=101132&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Apr 13 10:07:45 2010
@@ -4577,14 +4577,16 @@
     }
   }
 
-  //       -- has a class type (i.e., T2 is a class type) and can be
-  //          implicitly converted to an lvalue of type "cv3 T3,"
-  //          where "cv1 T1" is reference-compatible with "cv3 T3"
-  //          92) (this conversion is selected by enumerating the
-  //          applicable conversion functions (13.3.1.6) and choosing
-  //          the best one through overload resolution (13.3)),
+  //       -- has a class type (i.e., T2 is a class type), where T1 is
+  //          not reference-related to T2, and can be implicitly
+  //          converted to an lvalue of type "cv3 T3," where "cv1 T1"
+  //          is reference-compatible with "cv3 T3" 92) (this
+  //          conversion is selected by enumerating the applicable
+  //          conversion functions (13.3.1.6) and choosing the best
+  //          one through overload resolution (13.3)),
   if (!isRValRef && !SuppressUserConversions && T2->isRecordType() &&
-      !RequireCompleteType(DeclLoc, T2, 0)) {
+      !RequireCompleteType(DeclLoc, T2, 0) && 
+      RefRelationship == Ref_Incompatible) {
     CXXRecordDecl *T2RecordDecl
       = dyn_cast<CXXRecordDecl>(T2->getAs<RecordType>()->getDecl());
 

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp?rev=101132&r1=101131&r2=101132&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp Tue Apr 13 10:07:45 2010
@@ -22,3 +22,19 @@
     T bar = S();
   }
 }
+
+namespace PR6066 {
+  struct B { };
+  struct A : B {
+    operator B*();
+    operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}}
+  };
+
+  void f(B&); // no rvalues accepted
+  void f(B*);
+
+  int g() {
+    f(A()); // calls f(B*)
+    return 0;
+  }
+}





More information about the cfe-commits mailing list