r199512 - Don't allow 'this' within typedefs within classes that otherwise look like they
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jan 17 13:01:19 PST 2014
Author: rsmith
Date: Fri Jan 17 15:01:18 2014
New Revision: 199512
URL: http://llvm.org/viewvc/llvm-project?rev=199512&view=rev
Log:
Don't allow 'this' within typedefs within classes that otherwise look like they
might be member function declarations. Patch by Harald van Dijk!
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=199512&r1=199511&r2=199512&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jan 17 15:01:18 2014
@@ -5155,6 +5155,7 @@ void Parser::ParseFunctionDeclarator(Dec
// FIXME: currently, "static" case isn't handled correctly.
bool IsCXX11MemberFunction =
getLangOpts().CPlusPlus11 &&
+ D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef &&
(D.getContext() == Declarator::MemberContext
? !D.getDeclSpec().isFriendSpecified()
: D.getContext() == Declarator::FileContext &&
Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp?rev=199512&r1=199511&r2=199512&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp Fri Jan 17 15:01:18 2014
@@ -6,6 +6,8 @@ struct S {
int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}}
int sz = sizeof(this); // ok
+
+ typedef auto f() -> decltype(this); // expected-error {{invalid use of 'this' outside of a non-static member function}}
};
namespace CaptureThis {
More information about the cfe-commits
mailing list