diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-05 00:07:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-05 00:07:25 +0000 |
commit | 5e02c47a7085831586344a9728763cb50540c7f7 (patch) | |
tree | 5b547f0ae7da6c90cd5b3d6096106b205dc43cd8 /lib/Parse/ParseDecl.cpp | |
parent | 532e19b4e18585d959065e407c51e625baf26d81 (diff) |
sink a call to TryAnnotateCXXScopeToken down into the
applicable cases in ParseDeclarationSpecifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index aaf8621294..c063654781 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -438,32 +438,31 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS) { /// [C++] 'explicit' /// void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, - TemplateParameterLists *TemplateParams) -{ + TemplateParameterLists *TemplateParams){ DS.SetRangeStart(Tok.getLocation()); while (1) { int isInvalid = false; const char *PrevSpec = 0; SourceLocation Loc = Tok.getLocation(); - // Only annotate C++ scope. Allow class-name as an identifier in case - // it's a constructor. - if (getLang().CPlusPlus) - TryAnnotateCXXScopeToken(); - switch (Tok.getKind()) { default: // Try to parse a type-specifier; if we found one, continue. If it's not // a type, this falls through. - if (MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams)) { + if (MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams)) continue; - } DoneWithDeclSpec: // If this is not a declaration specifier token, we're done reading decl // specifiers. First verify that DeclSpec's are consistent. DS.Finish(Diags, PP.getSourceManager(), getLang()); return; + + case tok::coloncolon: // ::foo::bar + // Annotate C++ scope specifiers. If we get one, loop. + if (TryAnnotateCXXScopeToken()) + continue; + goto DoneWithDeclSpec; case tok::annot_cxxscope: { if (DS.hasTypeSpecifier()) @@ -505,6 +504,12 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // typedef-name case tok::identifier: { + // In C++, check to see if this is a scope specifier like foo::bar::, if + // so handle it as such. This is important for ctor parsing. + if (getLang().CPlusPlus && + TryAnnotateCXXScopeToken()) + continue; + // This identifier can only be a typedef name if we haven't already seen // a type-specifier. Without this check we misparse: // typedef int X; struct Y { short X; }; as 'short int'. |