[cfe-commits] r91765 - in /cfe/trunk: lib/AST/Expr.cpp test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
Douglas Gregor
dgregor at apple.com
Fri Dec 18 23:07:47 PST 2009
Author: dgregor
Date: Sat Dec 19 01:07:47 2009
New Revision: 91765
URL: http://llvm.org/viewvc/llvm-project?rev=91765&view=rev
Log:
A CXXExprWithTemporaries expression is an lvalue if its subexpression
is an lvalue. Fixes PR5787.
Added:
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp (with props)
Modified:
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=91765&r1=91764&r2=91765&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Dec 19 01:07:47 2009
@@ -1213,6 +1213,16 @@
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;
}
Added: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp?rev=91765&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp (added)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp Sat Dec 19 01:07:47 2009
@@ -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();
+}
Propchange: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list