[cfe-commits] r134700 - in /cfe/trunk: lib/AST/ExprCXX.cpp lib/AST/ExprClassification.cpp test/SemaTemplate/unresolved-construct.cpp

Douglas Gregor dgregor at apple.com
Fri Jul 8 08:50:43 PDT 2011


Author: dgregor
Date: Fri Jul  8 10:50:43 2011
New Revision: 134700

URL: http://llvm.org/viewvc/llvm-project?rev=134700&view=rev
Log:
Teach CXXUnresolvedConstructExpr when it should be an
lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an
lvalue. Fixes PR10285 / <rdar://problem/9743926>.

Added:
    cfe/trunk/test/SemaTemplate/unresolved-construct.cpp   (with props)
Modified:
    cfe/trunk/lib/AST/ExprCXX.cpp
    cfe/trunk/lib/AST/ExprClassification.cpp

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=134700&r1=134699&r2=134700&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Fri Jul  8 10:50:43 2011
@@ -725,7 +725,10 @@
                                                  SourceLocation RParenLoc)
   : Expr(CXXUnresolvedConstructExprClass, 
          Type->getType().getNonReferenceType(),
-         VK_LValue, OK_Ordinary,
+         (Type->getType()->isLValueReferenceType() ? VK_LValue
+          :Type->getType()->isRValueReferenceType()? VK_XValue
+          :VK_RValue),
+         OK_Ordinary,
          Type->getType()->isDependentType(), true, true,
          Type->getType()->containsUnexpandedParameterPack()),
     Type(Type),

Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=134700&r1=134699&r2=134700&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Fri Jul  8 10:50:43 2011
@@ -117,7 +117,6 @@
   case Expr::UnresolvedLookupExprClass:
   case Expr::UnresolvedMemberExprClass:
   case Expr::CXXDependentScopeMemberExprClass:
-  case Expr::CXXUnresolvedConstructExprClass:
   case Expr::DependentScopeDeclRefExprClass:
     // ObjC instance variables are lvalues
     // FIXME: ObjC++0x might have different rules
@@ -295,6 +294,10 @@
     if (!Lang.CPlusPlus) return Cl::CL_PRValue;
     return ClassifyUnnamed(Ctx, cast<ExplicitCastExpr>(E)->getTypeAsWritten());
 
+  case Expr::CXXUnresolvedConstructExprClass:
+    return ClassifyUnnamed(Ctx, 
+                      cast<CXXUnresolvedConstructExpr>(E)->getTypeAsWritten());
+      
   case Expr::BinaryConditionalOperatorClass: {
     if (!Lang.CPlusPlus) return Cl::CL_PRValue;
     const BinaryConditionalOperator *co = cast<BinaryConditionalOperator>(E);

Added: cfe/trunk/test/SemaTemplate/unresolved-construct.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/unresolved-construct.cpp?rev=134700&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/unresolved-construct.cpp (added)
+++ cfe/trunk/test/SemaTemplate/unresolved-construct.cpp Fri Jul  8 10:50:43 2011
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+class A
+{
+public:
+    A() {}
+
+    template <class _F>
+        explicit A(_F&& __f);
+
+    A(A&&) {}
+    A& operator=(A&&) {return *this;}
+};
+
+template <class T>
+void f(T t)
+{
+  A a;
+  a = f(t);
+}

Propchange: cfe/trunk/test/SemaTemplate/unresolved-construct.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/SemaTemplate/unresolved-construct.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/SemaTemplate/unresolved-construct.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list