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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 11:16:52 PST 2025


AaronBallman wrote:

> Ultimately we want
> 
>     1. I know all of these attributes, don't tell me about them
> 
>     2. I know all of these attribute namespaces, don't tell me about them - which this patch is doing
> 
>     3. Have a way to disable unknown attributes warnings for all unknown namespaces - which this patch is doing by introducing a separate flag
> 
> 
> I sort of question the last bullet point (the original issue), as it's a bit of a nuclear option. But maybe that's fine. Then there is the question of whether 1. and 2. should have separate interfaces.
> 
> I will also point out that `-Wunknown-attribute-namespaces=foo` is a very weird way to spell "I know about `foo`, don't warn on it" - and I am concerned about discoverability.

Yeah, I was thinking about the converse: `-Wno-unknown-attribute-namespaces=foo` seems almost like it's how we'd want to spell it, but that's pretty novel.

> And again, I apologize I did not see this patch sooner @a-tarasyuk. What do people think about landing it early in the Clang 21 cycle, in case we find a better long term interface in the next few months?

I think it makes sense to not land this for Clang 20 so we can get the interface right the first time.

Let's see if we have some agreement on where we're at.

1) We want `-Wunknown-attributes` to print attribute namespace names, but that's a separate PR from this one.
2) We have a user who wants a way to silence diagnostics about all unknown attributes if the attribute namespace itself is unknown.
3) We don't necessarily need to let the user specify a set of which unknown attribute namespaces to warn about. We could wait on this until there's user demand with a real world example.
4) Given that unknown attribute namespaces are uncommon, nothing needs to be done in a rush, we may even decide we don't need this option at all despite (2).

Does that seem like an accurate summary?

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


More information about the cfe-commits mailing list