[clang] [clang] Support [[]] spelling for noderef (PR #190100)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 2 10:03:13 PDT 2026
================
@@ -4688,8 +4681,20 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
}
}
+ // GNU attributes on a declaration (e.g., __attribute__((noderef)) int *p;)
+ // are parsed as part of the DeclSpec, but they are intended to apply to
+ // the first pointer or array declarator chunk encountered. Standard
+ // C++11 attribute syntax `[[clang::noderef]]` has stricter placement
+ // rules and should not "float" to the pointer. If a standard noderef
+ // attribute is found on the DeclSpec, we skip setting `ExpectNoDerefChunk`
+ // to ensure it is diagnosed for being applied to a non-pointer type,
+ // rather than silently moving it to the pointer.
bool ExpectNoDerefChunk =
- state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
+ std::any_of(state.getCurrentAttributes().begin(),
----------------
zwuis wrote:
We could use `llvm::any_of`.
https://github.com/llvm/llvm-project/pull/190100
More information about the cfe-commits
mailing list