[clang] [clang] Fix `gnu::init_priority` attribute handling for reserved values (PR #121577)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 17 05:28:25 PST 2025
philnik777 wrote:
> > Allow values within the range 0-100 of init_priority to be used outside system library, but with a warning
>
> This was an intentional decision, not a bug or an oversight (I'm sorry, I didn't see that @philnik777 had marked this a good first issue!). See #67673 for details. Basically: a warning is insufficient because it provides zero protection for the real world uses of the attribute. Reserved in this case really does mean "you only get to use those values if you're a system header" and we live with the "hole" that GNU line markers provide.
>
> I don't think we should move forward with this change unless there's a strong need to do so.
While this is a valid concern, I don't think it's much of a problem in reality. GCC just warns on this (not even an error by default) and I wasn't able to find a single use outside implementations of the reserved value range. For that reason I don't think we should make life unnecessarily hard for implementations. Using line markers is a huge burden, since they are anything but readable, people don't know what they are, and they are really easy to get wrong when modifying code, since you have to hard-code the line number. When you have a warning that's by default an error I don't see many people disabling that to stomp on implementers' toes.
https://github.com/llvm/llvm-project/pull/121577
More information about the cfe-commits
mailing list