]> granicus.if.org Git - clang/commitdiff
PR8800: When building a conversion to A& using a member operatorA&(), do not require...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 13 Jul 2011 22:53:21 +0000 (22:53 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 13 Jul 2011 22:53:21 +0000 (22:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/conversion-function.cpp

index b6045123fe2189f4982e1d47ce5467c04be01325..b95b886efbe34ba500a16fe1afdb93975707072d 100644 (file)
@@ -4535,19 +4535,19 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
                                 CK_FunctionToPointerDecay,
                                 &ConversionRef, VK_RValue);
 
-  QualType CallResultType
-    = Conversion->getConversionType().getNonLValueExprType(Context);
-  if (RequireCompleteType(From->getLocStart(), CallResultType, 0)) {
+  QualType ConversionType = Conversion->getConversionType();
+  if (RequireCompleteType(From->getLocStart(), ConversionType, 0)) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_bad_final_conversion;
     return;
   }
 
-  ExprValueKind VK = Expr::getValueKindForType(Conversion->getConversionType());
+  ExprValueKind VK = Expr::getValueKindForType(ConversionType);
 
   // Note that it is safe to allocate CallExpr on the stack here because
   // there are 0 arguments (i.e., nothing is allocated using ASTContext's
   // allocator).
+  QualType CallResultType = ConversionType.getNonLValueExprType(Context);
   CallExpr Call(Context, &ConversionFn, 0, 0, CallResultType, VK,
                 From->getLocStart());
   ImplicitConversionSequence ICS =
index aa47ae0f4825550e0d3cf7567cb9c55c6dfdb800..a7a178244c80dd0de74eae4676d332be5a5a7290 100644 (file)
@@ -378,3 +378,17 @@ namespace PR9336 {
   generic_list<generic_list<int> > l;
   array<array<int> > a = l;
 }
+
+namespace PR8800 {
+  struct A;
+  struct C {
+    operator A&();
+  };
+  void f() {
+    C c;
+    A& a1(c);
+    A& a2 = c;
+    A& a3 = static_cast<A&>(c);
+    A& a4 = (A&)c;
+  }
+}