[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 24 06:46:52 PST 2025
AaronBallman wrote:
> > Thanks for this patch.
> > Sorry I did not see this sooner.
> > I am not convinced this the best way to resolve #120875 - and I suspect in practice it would be a bit difficult to use/be under used.
>
> I'm not convinced here? I think a flag that says "warn me about unknown namespaces" is particularly useful, but the effect of "don't warn me about unknown namespaces, but warn me about attributes in known namespaces" _IS_ also particularly useful. (that is, if you don't know the namespace, shush, else tell me about it).
+1
> > I think the general desire is for users to have a way (maybe a file) where they can list all the attributes they want the implementation to ignore when unknown (with their namespaces).
>
> If anything, a list on a command line as an extension to this (that is, don't warn me about THIS LIST of unknown namespaces) would be incredibly useful, something like: `-Wno-unknown-namespace-attributes=my_static_analysis_tool,my_annotation`. But I think this is independently useful without it .
That's how this already works in this patch:
```
// RUN: %clang_cc1 -fsyntax-only -Wunknown-attribute-namespaces=foo,bar -std=c23 \
// RUN: %s 2>&1 | FileCheck %s --check-prefixes=CHECK_UNKNOWN_ATTR_NS
```
I think what Corentin is asking for is a similar (follow-up?) feature that allows you to say "warn me about unknown attributes, but not <this specific set> of unknown attributes." that can take attributes with or without a namespace.
Btw, I just realized we only have tests for `-Wunknown-attribute-namespaces=foo,bar` but not for `-Wno-unknown-attribute-namespaces=foo,bar`; we should test that behavior too.
>> I think we should definitely display the namespace name in the current diagnostic
I'm in total support of that, though not as part of this PR.
https://github.com/llvm/llvm-project/pull/120925
More information about the cfe-commits
mailing list