|
@@ -1741,9 +1741,10 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
|
|
/// [C++11/C11] static_assert-declaration
|
|
/// [C++11/C11] static_assert-declaration
|
|
/// others... [FIXME]
|
|
/// others... [FIXME]
|
|
///
|
|
///
|
|
-Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
|
|
|
|
- SourceLocation &DeclEnd,
|
|
|
|
- ParsedAttributesWithRange &attrs) {
|
|
|
|
|
|
+Parser::DeclGroupPtrTy
|
|
|
|
+Parser::ParseDeclaration(DeclaratorContext Context, SourceLocation &DeclEnd,
|
|
|
|
+ ParsedAttributesWithRange &attrs,
|
|
|
|
+ SourceLocation *DeclSpecStart) {
|
|
ParenBraceBracketBalancer BalancerRAIIObj(*this);
|
|
ParenBraceBracketBalancer BalancerRAIIObj(*this);
|
|
// Must temporarily exit the objective-c container scope for
|
|
// Must temporarily exit the objective-c container scope for
|
|
// parsing c none objective-c decls.
|
|
// parsing c none objective-c decls.
|
|
@@ -1763,8 +1764,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
|
|
SourceLocation InlineLoc = ConsumeToken();
|
|
SourceLocation InlineLoc = ConsumeToken();
|
|
return ParseNamespace(Context, DeclEnd, InlineLoc);
|
|
return ParseNamespace(Context, DeclEnd, InlineLoc);
|
|
}
|
|
}
|
|
- return ParseSimpleDeclaration(Context, DeclEnd, attrs,
|
|
|
|
- true);
|
|
|
|
|
|
+ return ParseSimpleDeclaration(Context, DeclEnd, attrs, true, nullptr,
|
|
|
|
+ DeclSpecStart);
|
|
case tok::kw_namespace:
|
|
case tok::kw_namespace:
|
|
ProhibitAttributes(attrs);
|
|
ProhibitAttributes(attrs);
|
|
return ParseNamespace(Context, DeclEnd);
|
|
return ParseNamespace(Context, DeclEnd);
|
|
@@ -1777,7 +1778,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
|
|
SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
|
|
SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- return ParseSimpleDeclaration(Context, DeclEnd, attrs, true);
|
|
|
|
|
|
+ return ParseSimpleDeclaration(Context, DeclEnd, attrs, true, nullptr,
|
|
|
|
+ DeclSpecStart);
|
|
}
|
|
}
|
|
|
|
|
|
// This routine returns a DeclGroup, if the thing we parsed only contains a
|
|
// This routine returns a DeclGroup, if the thing we parsed only contains a
|
|
@@ -1802,11 +1804,14 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
|
|
/// If FRI is non-null, we might be parsing a for-range-declaration instead
|
|
/// If FRI is non-null, we might be parsing a for-range-declaration instead
|
|
/// of a simple-declaration. If we find that we are, we also parse the
|
|
/// of a simple-declaration. If we find that we are, we also parse the
|
|
/// for-range-initializer, and place it here.
|
|
/// for-range-initializer, and place it here.
|
|
-Parser::DeclGroupPtrTy
|
|
|
|
-Parser::ParseSimpleDeclaration(DeclaratorContext Context,
|
|
|
|
- SourceLocation &DeclEnd,
|
|
|
|
- ParsedAttributesWithRange &Attrs,
|
|
|
|
- bool RequireSemi, ForRangeInit *FRI) {
|
|
|
|
|
|
+///
|
|
|
|
+/// DeclSpecStart is used when decl-specifiers are parsed before parsing
|
|
|
|
+/// the Declaration. The SourceLocation for this Decl is set to
|
|
|
|
+/// DeclSpecStart if DeclSpecStart is non-null.
|
|
|
|
+Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(
|
|
|
|
+ DeclaratorContext Context, SourceLocation &DeclEnd,
|
|
|
|
+ ParsedAttributesWithRange &Attrs, bool RequireSemi, ForRangeInit *FRI,
|
|
|
|
+ SourceLocation *DeclSpecStart) {
|
|
// Parse the common declaration-specifiers piece.
|
|
// Parse the common declaration-specifiers piece.
|
|
ParsingDeclSpec DS(*this);
|
|
ParsingDeclSpec DS(*this);
|
|
|
|
|
|
@@ -1836,6 +1841,9 @@ Parser::ParseSimpleDeclaration(DeclaratorContext Context,
|
|
return Actions.ConvertDeclToDeclGroup(TheDecl);
|
|
return Actions.ConvertDeclToDeclGroup(TheDecl);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (DeclSpecStart)
|
|
|
|
+ DS.SetRangeStart(*DeclSpecStart);
|
|
|
|
+
|
|
DS.takeAttributesFrom(Attrs);
|
|
DS.takeAttributesFrom(Attrs);
|
|
return ParseDeclGroup(DS, Context, &DeclEnd, FRI);
|
|
return ParseDeclGroup(DS, Context, &DeclEnd, FRI);
|
|
}
|
|
}
|