[clang] [BoundsSafety] Support bounds-safety attributes in type positions (PR #179612)
Yeoul Na via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 09:53:49 PST 2026
================
@@ -4987,15 +5130,23 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
ParsedAttributes attrs(AttrFactory);
// If attributes exist after struct contents, parse them.
- MaybeParseGNUAttributes(attrs, &LateFieldAttrs);
+ MaybeParseGNUAttributes(attrs);
// Late parse field attributes if necessary.
ParseLexedCAttributeList(LateFieldAttrs, /*EnterScope=*/false);
-
SmallVector<Decl *, 32> FieldDecls(TagDecl->fields());
Actions.ActOnFields(getCurScope(), RecordLoc, TagDecl, FieldDecls,
T.getOpenLocation(), T.getCloseLocation(), attrs);
+ Scope *ParentScope = getCurScope()->getParent();
+ assert(ParentScope);
+ // Process late-parsed type attributes for the outermost record. Nested
+ // non-anonymous records are handled immediately after their declaration is
+ // parsed, which is when it is known whether the record is anonymous.
+ if (getLangOpts().ExperimentalLateParseAttributes &&
+ !ParentScope->getEntity()->isRecord())
----------------
rapidsna wrote:
Oh I will check. Though I suspect `clang/test/C/C23/n3037.c` is failing for a different reason because the condition is guarded under `ExperimentalLateParseAttributes` (`-fexperimental-late-parse-attributes`) and `n3037.c` doesn't enable it.
https://github.com/llvm/llvm-project/pull/179612
More information about the cfe-commits
mailing list