forked from OSchip/llvm-project
A CXXExprWithTemporaries expression is an lvalue if its subexpression
is an lvalue. Fixes PR5787. llvm-svn: 91765
This commit is contained in:
parent
740ab38bb7
commit
5103effb1d
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue