[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 07:28:09 PST 2025
philnik777 wrote:
> > 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.
>
> I wouldn't expect to find uses within the reserved value range except in system headers given that we have an error.
Since GCC doesn't reject it I don't see why you'd expect zero instances. AFAIK there's lots of code that only compiles with GCC.
> > 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.
>
> I disagree. There's no value to a reserved range that's not actually reserved. You can use GNU line markers, but if you find those distasteful (which is reasonable), there's also `#pragma GCC system_header` as well.
`#pragma GCC system_header` only works on headers, and even in that case it's horrible for testing. If you want warnings when testing the implementation you'd have to put the variable into its own header just to add the pragma specifically to that.
https://github.com/llvm/llvm-project/pull/121577
More information about the cfe-commits
mailing list