A CXXExprWithTemporaries expression is an lvalue if its subexpression

is an lvalue. Fixes PR5787.

llvm-svn: 91765
This commit is contained in:
Douglas Gregor 2009-12-19 07:07:47 +00:00
parent 740ab38bb7
commit 5103effb1d
2 changed files with 29 additions and 0 deletions

View File

@ -1213,6 +1213,16 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
return LV_Valid;
}
case Expr::CXXExprWithTemporariesClass:
return cast<CXXExprWithTemporaries>(this)->getSubExpr()->isLvalue(Ctx);
case Expr::ObjCMessageExprClass:
if (const ObjCMethodDecl *Method
= cast<ObjCMessageExpr>(this)->getMethodDecl())
if (Method->getResultType()->isLValueReferenceType())
return LV_Valid;
break;
default:
break;
}

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR5787
class C {
public:
~C() {}
};
template <typename T>
class E {
public:
E& Foo(const C&);
E& Bar() { return Foo(C()); }
};
void Test() {
E<int> e;
e.Bar();
}