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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 10:17:37 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'}}
----------------
erichkeane wrote:

Ah, yeah.  I think we need to fix this ASAP.  the `push` pragma needs to not consider `void` to be a `parameter` (even if it is a `ParmVarDecl` at one point).  

Whether it needs to be fixed in THIS patch, or a followup (since we jsut did the branch, we at least have some time), I'll leave up to the author.

Side note: `pragma clang attribute push` diagnostics are THE WORST here.  The fact that the error/warning is on the attribute location, but doesn't point out which declaration is causing it is awful.  We should probably find some way to intuit that we should probably have a 'note' here that ALSO points out which declaration it applies to.



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


More information about the cfe-commits mailing list