@@ -4944,6 +4944,24 @@ void Parser::ParseStructDeclaration(
4944
4944
}
4945
4945
}
4946
4946
4947
+ // TODO: All callers of this function should be moved to
4948
+ // `Parser::ParseLexedAttributeList`.
4949
+ void Parser::ParseLexedCAttributeList (LateParsedAttrList &LAs, bool EnterScope,
4950
+ ParsedAttributes *OutAttrs) {
4951
+ assert (LAs.parseSoon () &&
4952
+ " Attribute list should be marked for immediate parsing." );
4953
+ #ifndef NDEBUG
4954
+ auto Lang =
4955
+ LangStandard::getLangStandardForKind (getLangOpts ().LangStd ).getLanguage ();
4956
+ assert (Lang == Language::C || Lang == Language::OpenCL);
4957
+ #endif
4958
+ for (auto *LA : LAs) {
4959
+ ParseLexedCAttribute (*LA, OutAttrs);
4960
+ delete LA;
4961
+ }
4962
+ LAs.clear ();
4963
+ }
4964
+
4947
4965
// / Finish parsing an attribute for which parsing was delayed.
4948
4966
// / This will be called at the end of parsing a class declaration
4949
4967
// / for each LateParsedAttribute. We consume the saved tokens and
@@ -5032,7 +5050,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
5032
5050
5033
5051
// `LateAttrParseExperimentalExtOnly=true` requests that only attributes
5034
5052
// marked with `LateAttrParseExperimentalExt` are late parsed.
5035
- LateParsedAttrList LateFieldAttrs (/* PSoon=*/ false ,
5053
+ LateParsedAttrList LateFieldAttrs (/* PSoon=*/ true ,
5036
5054
/* LateAttrParseExperimentalExtOnly=*/ true );
5037
5055
5038
5056
// While we still have something to read, read the declarations in the struct.
@@ -5141,9 +5159,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
5141
5159
MaybeParseGNUAttributes (attrs, &LateFieldAttrs);
5142
5160
5143
5161
// Late parse field attributes if necessary.
5144
- assert (!getLangOpts ().CPlusPlus );
5145
- for (auto *LateAttr : LateFieldAttrs)
5146
- ParseLexedCAttribute (*LateAttr);
5162
+ ParseLexedCAttributeList (LateFieldAttrs, /* EnterScope=*/ false );
5147
5163
5148
5164
SmallVector<Decl *, 32 > FieldDecls (TagDecl->fields ());
5149
5165
0 commit comments