summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2012-04-19 23:17:45 +0000
committerKaelyn Uhrain <rikka@google.com>2012-04-19 23:17:45 +0000
commitb3967d7fdc86020571d9e5de7fe85167dd2f9b15 (patch)
tree72b50be578d238d2d465fcb29605d854cc786bc5 /clang/lib/Parse/ParseTentative.cpp
parent3c90f01bf041d6a9130b1f7fd76e575658c97f39 (diff)
downloadbcm5719-llvm-b3967d7fdc86020571d9e5de7fe85167dd2f9b15.tar.gz
bcm5719-llvm-b3967d7fdc86020571d9e5de7fe85167dd2f9b15.zip
In Parser::isCXXDeclarationSpecifier, consider a non-type identifier
followed by an identifier as declaration specificer (except for ObjC). This allows e.g. an out-of-line C++ member function definitions to be recognized as functions and not as variable declarations if the type name for the first parameter is not recognized as a type--say, when there is a function name shadowing an enum type name and the parameter is missing the "enum" keyword needed to distinguish the two. Note that returning TPResult::Error() instead of TPResult::True() appears to have the same end result, while TPResult::Ambiguous() results in a crash. llvm-svn: 155163
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r--clang/lib/Parse/ParseTentative.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 28c5e8b6737..b5251a61777 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -931,8 +931,12 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult) {
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return TPResult::Error();
- if (Tok.is(tok::identifier))
- return TPResult::False();
+ if (Tok.is(tok::identifier)) {
+ const Token &Next = NextToken();
+ bool NotObjC = !(getLangOpts().ObjC1 || getLangOpts().ObjC2);
+ return (NotObjC && Next.is(tok::identifier)) ?
+ TPResult::True() : TPResult::False();
+ }
return isCXXDeclarationSpecifier(BracedCastResult);
case tok::coloncolon: { // ::foo::bar
OpenPOWER on IntegriCloud