diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-08 15:50:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-08 15:50:43 +0000 |
commit | 032c86921177031ecbb46c398b3e710758ba915e (patch) | |
tree | 67dcb165082b840302ec061c3865d478a167254c | |
parent | fd8bcd2520bd107ae5699536d776ed39487a5e6e (diff) |
Teach CXXUnresolvedConstructExpr when it should be an
lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an
lvalue. Fixes PR10285 / <rdar://problem/9743926>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134700 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ExprCXX.cpp | 5 | ||||
-rw-r--r-- | lib/AST/ExprClassification.cpp | 5 | ||||
-rw-r--r-- | test/SemaTemplate/unresolved-construct.cpp | 19 |
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 32209f6be6..f92afffb58 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -725,7 +725,10 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 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), diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 2a05c1fccf..f75a56c39e 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -117,7 +117,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { 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 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { 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); diff --git a/test/SemaTemplate/unresolved-construct.cpp b/test/SemaTemplate/unresolved-construct.cpp new file mode 100644 index 0000000000..0d1ba17a01 --- /dev/null +++ b/test/SemaTemplate/unresolved-construct.cpp @@ -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); +} |