[clang] [Clang] disallow attributes on void parameters (PR #124920)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 31 05:44:29 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:
```suggestion
#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), variable, enum))
// expected-warning at -1 {{attribute 'abi_tag' cannot be applied to a 'void' parameter}}
// expected-error at -2 {{attribute 'abi_tag' cannot be applied to 'enum'}}
```
I *think* this is actually a bug with the way `clang attribute push` works. A `void` parameter is not a variable because it doesn't really declare a parameter (there's no object backing the parameter like there is for other cases). WDYT @erichkeane?
https://github.com/llvm/llvm-project/pull/124920
More information about the cfe-commits
mailing list