[cfe-commits] r123950 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp

Douglas Gregor dgregor at apple.com
Thu Jan 20 16:27:08 PST 2011


Author: dgregor
Date: Thu Jan 20 18:27:08 2011
New Revision: 123950

URL: http://llvm.org/viewvc/llvm-project?rev=123950&view=rev
Log:
When performing reference binding via a conversion function, perform
type checking based on the actual reference type we're trying to bind
the result to, rather than stripping the reference.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=123950&r1=123949&r2=123950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jan 20 18:27:08 2011
@@ -2363,11 +2363,6 @@
     // functions.
     CXXRecordDecl *T2RecordDecl = cast<CXXRecordDecl>(T2RecordType->getDecl());
 
-    // Determine the type we are converting to. If we are allowed to
-    // convert to an rvalue, take the type that the destination type
-    // refers to.
-    QualType ToType = AllowRValues? cv1T1 : DestType;
-
     const UnresolvedSetImpl *Conversions
       = T2RecordDecl->getVisibleConversionFunctions();
     for (UnresolvedSetImpl::const_iterator I = Conversions->begin(),
@@ -2395,10 +2390,10 @@
         if (ConvTemplate)
           S.AddTemplateConversionCandidate(ConvTemplate, I.getPair(),
                                            ActingDC, Initializer,
-                                           ToType, CandidateSet);
+                                           DestType, CandidateSet);
         else
           S.AddConversionCandidate(Conv, I.getPair(), ActingDC,
-                                   Initializer, ToType, CandidateSet);
+                                   Initializer, DestType, CandidateSet);
       }
     }
   }

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp?rev=123950&r1=123949&r2=123950&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp Thu Jan 20 18:27:08 2011
@@ -22,7 +22,6 @@
 
 void test_rvalue_refs() {
   // If the initializer expression...
-
   //   - is an xvalue, class prvalue, array prvalue or function lvalue
   //     and "cv1 T1" is reference-compatible with "cv2 T2", or
 
@@ -54,9 +53,9 @@
   // class prvalue
   Base&& base6 = ConvertsTo<Base>();
   Base&& base7 = ConvertsTo<Derived>();
-  
-  // FIXME: function lvalue
-  //  int (&&function1)(int) = ConvertsTo<int(&)(int)>();
+
+  // function lvalue
+  int (&&function1)(int) = ConvertsTo<int(&)(int)>();
 }
 
 class NonCopyable {





More information about the cfe-commits mailing list