@@ -1741,9 +1741,10 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
17411741// / [C++11/C11] static_assert-declaration
17421742// / others... [FIXME]
17431743// /
1744- Parser::DeclGroupPtrTy Parser::ParseDeclaration (DeclaratorContext Context,
1745- SourceLocation &DeclEnd,
1746- ParsedAttributesWithRange &attrs) {
1744+ Parser::DeclGroupPtrTy
1745+ Parser::ParseDeclaration (DeclaratorContext Context, SourceLocation &DeclEnd,
1746+ ParsedAttributesWithRange &attrs,
1747+ SourceLocation *DeclSpecStart) {
17471748 ParenBraceBracketBalancer BalancerRAIIObj (*this );
17481749 // Must temporarily exit the objective-c container scope for
17491750 // parsing c none objective-c decls.
@@ -1763,8 +1764,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
17631764 SourceLocation InlineLoc = ConsumeToken ();
17641765 return ParseNamespace (Context, DeclEnd, InlineLoc);
17651766 }
1766- return ParseSimpleDeclaration (Context, DeclEnd, attrs,
1767- true );
1767+ return ParseSimpleDeclaration (Context, DeclEnd, attrs, true , nullptr ,
1768+ DeclSpecStart );
17681769 case tok::kw_namespace:
17691770 ProhibitAttributes (attrs);
17701771 return ParseNamespace (Context, DeclEnd);
@@ -1777,7 +1778,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
17771778 SingleDecl = ParseStaticAssertDeclaration (DeclEnd);
17781779 break ;
17791780 default :
1780- return ParseSimpleDeclaration (Context, DeclEnd, attrs, true );
1781+ return ParseSimpleDeclaration (Context, DeclEnd, attrs, true , nullptr ,
1782+ DeclSpecStart);
17811783 }
17821784
17831785 // This routine returns a DeclGroup, if the thing we parsed only contains a
@@ -1802,11 +1804,14 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
18021804// / If FRI is non-null, we might be parsing a for-range-declaration instead
18031805// / of a simple-declaration. If we find that we are, we also parse the
18041806// / for-range-initializer, and place it here.
1805- Parser::DeclGroupPtrTy
1806- Parser::ParseSimpleDeclaration (DeclaratorContext Context,
1807- SourceLocation &DeclEnd,
1808- ParsedAttributesWithRange &Attrs,
1809- bool RequireSemi, ForRangeInit *FRI) {
1807+ // /
1808+ // / DeclSpecStart is used when decl-specifiers are parsed before parsing
1809+ // / the Declaration. The SourceLocation for this Decl is set to
1810+ // / DeclSpecStart if DeclSpecStart is non-null.
1811+ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration (
1812+ DeclaratorContext Context, SourceLocation &DeclEnd,
1813+ ParsedAttributesWithRange &Attrs, bool RequireSemi, ForRangeInit *FRI,
1814+ SourceLocation *DeclSpecStart) {
18101815 // Parse the common declaration-specifiers piece.
18111816 ParsingDeclSpec DS (*this );
18121817
@@ -1836,6 +1841,9 @@ Parser::ParseSimpleDeclaration(DeclaratorContext Context,
18361841 return Actions.ConvertDeclToDeclGroup (TheDecl);
18371842 }
18381843
1844+ if (DeclSpecStart)
1845+ DS.SetRangeStart (*DeclSpecStart);
1846+
18391847 DS.takeAttributesFrom (Attrs);
18401848 return ParseDeclGroup (DS, Context, &DeclEnd, FRI);
18411849}
0 commit comments