[clang] [Clang] disallow attributes on void parameters (PR #124920)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 2 06:20:57 PST 2025
================
@@ -50,8 +50,8 @@ struct testRecoverStrictnessStruct { };
#pragma clang attribute pop
-#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), variable, enum))
-// expected-error at -1 {{attribute 'abi_tag' cannot be applied to 'enum'}}
+#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), variable, enum)) // expected-warning {{attribute 'abi_tag' cannot be applied to a 'void' parameter}}
+ // expected-error at -1 {{attribute 'abi_tag' cannot be applied to 'enum'}}
----------------
a-tarasyuk wrote:
@AaronBallman if we're considering changes to `Attr.td`, it seems that `[Var]` and `[ParmVar]` should be extended to `AttrSubject`, since `AttrSubjectMatcherRule` only accepts a list of `AttrSubject`. I'm unsure if this qualifies as a `Subject`, though...
https://github.com/llvm/llvm-project/blob/50082773223b9eced296d8223ca4e4a79ecdeb9b/clang/include/clang/Basic/Attr.td#L560-L567
or explicitly add a helper to exclude void parameters and use it with
https://github.com/llvm/llvm-project/blob/d00579be39e8a470d7a0ff79ff6deadf9e003781/clang/lib/Sema/ParsedAttr.cpp#L172-L175
> Side note: pragma clang attribute push diagnostics are THE WORST here...
I suppose the diagnostic for void parameters will be skipped if the rules exclude them, or should the diagnostic still handle this case?
https://github.com/llvm/llvm-project/pull/124920
More information about the cfe-commits
mailing list