[clang] [llvm] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

Erich Keane via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 07:46:29 PST 2025


erichkeane wrote:


> Yes, but the point is: these names aren't reserved but the pain can still happen. e.g., `cdecl` is not a reserved identifier, but re-defining its meaning can still break code in ways that could have better diagnostics: https://godbolt.org/z/vTfWPsYj9. Though, I suppose to reduce the chattiness, we could elect to diagnose when we see an attribute that is ill-formed due to the macro. e.g.,

THIS is interesting, and I'd be much more agreeable with a patch for ALL attributes, though I think this patch stands on its own.  I agree the danger is equal for both.  

> If we're only going to diagnose conflicts with standard attribute names, then I can squint enough to agree. But I think that's an arbitrary limitation; we all just agreed that this isn't about using a reserved identifier so much as about writing a macro which will conflict with uses of attributes of the same name.

I think it is actually about BOTH.  We have diagnostics that say "you're using a reserved thing", and this is a time where you are using a reserved thing, which is independently valuable.  The REST (conflicting with an attribute name) is a different, yet perhaps equally/more useful (in a different way) diagnostic.

IN SUMMARY: I think this proposal minus the `std` check is acceptable.  I think the proposed-not-implemented warning of "you messed with an attribute name, and it is doing weird stuff" is also a very valuable, though different, check.

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


More information about the llvm-commits mailing list