[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 11:39:42 PST 2025


================
@@ -822,6 +822,7 @@ def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def NSConsumedMismatch : DiagGroup<"nsconsumed-mismatch">;
 def NSReturnsMismatch : DiagGroup<"nsreturns-mismatch">;
 
+def UnknownAttributeNamespaces : DiagGroup<"unknown-attribute-namespaces">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;
 def UnknownAttributes : DiagGroup<"unknown-attributes">;
----------------
AaronBallman wrote:

I think the warning group makes sense to add to `UnknownAttributes` because I think the behavior we want is:
```
// -Wunknow-attributes; tell me about all kinds of unknown attributes
[[frob::foo]][[gnu::fd_arg]] void func();
// warning: unknown attribute namespace 'frob'; attribute 'frob::foo' ignored [-Wuknown-attribute-namespaces]
// warning: unknown attribute 'fd_arg' ignored [-Wunknown-attributes]

// -Wunknown-attributes -Wno-unknown-attribute-namespaces; only tell me about unknown attributes in a known attribute namespace
[[frob::foo]][[gnu::fd_arg]] void func();
// warning: unknown attribute 'foo' ignored [-Wuknown-attributes]

// -Wno-unknown-attributes -Wunknown-attribute-namespaces; only tell me about unknown attribute namespaces
[[frob::foo]][[gnu::fd_arg]] void func();
// warning: unknown attribute namespace 'frob'; attribute 'frob::foo' ignored [-Wuknown-attribute-namespaces]

// -Wno-unknown-attributes; don't tell me about unknown attributes at all
[[frob::foo]][[gnu::fd_arg]] void func(); // no warnings
```
WDYT? If you agree, this would be a pretty useful test case to add.

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


More information about the cfe-commits mailing list