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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 13 06:07:12 PST 2025


================
@@ -179,6 +179,8 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
+def ext_unknown_attribute_ignored : Extension<
+  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
----------------
AaronBallman wrote:

> Curiously, and after I sent that, I realized why WE of all compilers SHOULD warn here, even if others don't. Clang supports/recognizes the prefixes of all of the major compilers, which drastically increases the chance that an unrecognized one is a typo rather than an intentional difference.

+1; the current behavior of warning even when we don't know the namespace is entirely intentional for exactly that reason.

I think it's reasonable for us to have a new warning group so if there is an attribute namespace heavily used in a project, the developer can disable just the unknown namespace ones while still getting other diagnostics about unknown attributes. However, what should the user do when they want to silence diagnostics about `[[frobble::gobble]]` but not silence diagnostics about `[[edg::whatever]]`? Do we want to support a grouping like `-Wno-unknown-attribute-namespace=frobble` where leaving off the `=` means we silence all unknown attribute namespaces?

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


More information about the cfe-commits mailing list