]> granicus.if.org Git - clang/commitdiff
PR11009: Fix a FIXME which was leading to an assertion failure with rvalue references.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 27 Sep 2011 01:11:35 +0000 (01:11 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 27 Sep 2011 01:11:35 +0000 (01:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140594 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/SemaCXX/rval-references.cpp

index 0c518c7bda1c84ea82d2cb432859c8f1a4fd3c7f..e61fe2d519571b726aad88df8bae89b89f5b23c6 100644 (file)
@@ -4482,7 +4482,6 @@ InitializationSequence::Perform(Sema &S,
       FunctionDecl *Fn = Step->Function.Function;
       DeclAccessPair FoundFn = Step->Function.FoundDecl;
       bool CreatedObject = false;
-      bool IsLvalue = false;
       if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) {
         // Build a call to the selected constructor.
         ASTOwningVector<Expr*> ConstructorArgs(S);
@@ -4520,7 +4519,6 @@ InitializationSequence::Perform(Sema &S,
       } else {
         // Build a call to the conversion function.
         CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn);
-        IsLvalue = Conversion->getResultType()->isLValueReferenceType();
         S.CheckMemberOperatorAccess(Kind.getLocation(), CurInit.get(), 0,
                                     FoundFn);
         S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation());
@@ -4560,11 +4558,10 @@ InitializationSequence::Perform(Sema &S,
         }
       }
 
-      // FIXME: xvalues
       CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
                                                  CurInit.get()->getType(),
                                                  CastKind, CurInit.get(), 0,
-                                           IsLvalue ? VK_LValue : VK_RValue));
+                                                CurInit.get()->getValueKind()));
 
       if (RequiresCopy)
         CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity,
index 74afdbe41043cadd5f98902b6312988b3049ea55..38b45a530fd1ea034b8e2f5c32c8f5a2ba429e0a 100644 (file)
@@ -92,3 +92,11 @@ MoveOnly returningNonEligible() {
   else // Construction from different type can't be elided
     return i; // expected-error {{no viable conversion from 'int' to 'MoveOnly'}}
 }
+
+// PR11009
+struct MoveConvertible {
+  operator int&& () const;
+};
+void moveConstruct() {
+  (void)(int)MoveConvertible();
+}