[clang] [Clang] disallow attributes on void parameters (PR #124920)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 10:22:28 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'}}
----------------
AaronBallman wrote:

I think we can fix the behavior here by updating somewhere around https://github.com/llvm/llvm-project/blob/eb0af4e48d0e039849c6bbf36e791610e7ef9a06/clang/utils/TableGen/ClangAttrEmitter.cpp#L4473

That's what gets used by `ParsedAttr::appliesToDecl()` which is called by `Sema::AddPragmaAttributes()`.

https://github.com/llvm/llvm-project/pull/124920


More information about the cfe-commits mailing list