[cfe-commits] r140594 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/SemaCXX/rval-references.cpp

Eli Friedman eli.friedman at gmail.com
Mon Sep 26 18:11:35 PDT 2011


Author: efriedma
Date: Mon Sep 26 20:11:35 2011
New Revision: 140594

URL: http://llvm.org/viewvc/llvm-project?rev=140594&view=rev
Log:
PR11009: Fix a FIXME which was leading to an assertion failure with rvalue references.


Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/SemaCXX/rval-references.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=140594&r1=140593&r2=140594&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Sep 26 20:11:35 2011
@@ -4482,7 +4482,6 @@
       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 @@
       } 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 @@
         }
       }
 
-      // 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,

Modified: cfe/trunk/test/SemaCXX/rval-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/rval-references.cpp?rev=140594&r1=140593&r2=140594&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/rval-references.cpp (original)
+++ cfe/trunk/test/SemaCXX/rval-references.cpp Mon Sep 26 20:11:35 2011
@@ -92,3 +92,11 @@
   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();
+}





More information about the cfe-commits mailing list