diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index f352efa872..a76c5c66f2 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -558,10 +558,27 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, /// [GNU] restrict /// Parser::TPResult Parser::isCXXDeclarationSpecifier() { - // Annotate typenames and C++ scope specifiers. - TryAnnotateTypeOrScopeToken(); - switch (Tok.getKind()) { + case tok::identifier: // foo::bar + // Annotate typenames and C++ scope specifiers. If we get one, just + // recurse to handle whatever we get. + if (TryAnnotateTypeOrScopeToken()) + return isCXXDeclarationSpecifier(); + // Otherwise, not a typename. + return TPResult::False(); + + case tok::coloncolon: // ::foo::bar + if (NextToken().is(tok::kw_new) || // ::new + NextToken().is(tok::kw_delete)) // ::delete + return TPResult::False(); + + // Annotate typenames and C++ scope specifiers. If we get one, just + // recurse to handle whatever we get. + if (TryAnnotateTypeOrScopeToken()) + return isCXXDeclarationSpecifier(); + // Otherwise, not a typename. + return TPResult::False(); + // decl-specifier: // storage-class-specifier // type-specifier