diff options
author | David Blaikie <dblaikie@gmail.com> | 2011-10-25 17:10:12 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2011-10-25 17:10:12 +0000 |
commit | 22216eb4fb0936d2488fc03abd285d135c36ff01 (patch) | |
tree | 54cb3fc7ff30ef1c709e1525898dcbfc54591a0f /lib/Parse/ParseDeclCXX.cpp | |
parent | 09048df0b3f472091b2204e531d6b6019244884b (diff) |
Fix cases where the optional nested-name-specifier erroneously preceeded a decltype-specification when specifying a base type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 9d2db2ae1c..10234ab892 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -711,8 +711,26 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) { /// identifier /// simple-template-id /// -Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &EndLocation, - CXXScopeSpec &SS) { +Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, + SourceLocation &EndLocation) { + // Parse decltype-specifier + if (Tok.is(tok::kw_decltype)) { + // Fake up a Declarator to use with ActOnTypeName. + DeclSpec DS(AttrFactory); + + ParseDecltypeSpecifier(DS); + EndLocation = DS.getSourceRange().getEnd(); + + Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); + } + + // Parse optional nested-name-specifier + CXXScopeSpec SS; + ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false); + + BaseLoc = Tok.getLocation(); + // Check whether we have a template-id that names a type. if (Tok.is(tok::annot_template_id)) { TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); @@ -733,17 +751,6 @@ Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &EndLocation, // Fall through to produce an error below. } - if (Tok.is(tok::kw_decltype)) { - // Fake up a Declarator to use with ActOnTypeName. - DeclSpec DS(AttrFactory); - - ParseDecltypeSpecifier(DS); - EndLocation = DS.getSourceRange().getEnd(); - - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); - return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); - } - if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_class_name); return true; @@ -1410,16 +1417,10 @@ Parser::BaseResult Parser::ParseBaseSpecifier(Decl *ClassDecl) { IsVirtual = true; } - // Parse optional '::' and optional nested-name-specifier. - CXXScopeSpec SS; - ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false); - - // The location of the base class itself. - SourceLocation BaseLoc = Tok.getLocation(); - // Parse the class-name. SourceLocation EndLocation; - TypeResult BaseType = ParseBaseTypeSpecifier(EndLocation, SS); + SourceLocation BaseLoc; + TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation); if (BaseType.isInvalid()) return true; |