[clang] Basic: Update the rule for whether to use FEATURE or EXTENSION. (PR #153104)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 13 15:58:17 PDT 2025
ojhunt wrote:
> > The same problem seems to affect `ptrauth_qualifier` with the PAuth ABI. For example, consider this TU:
>
> That's a similar ODR violation, but they also have a bug; `__ptrauth` is failing to emit a pedantic diagnostic for use of the extension at all. I think it's a different situation because there the user is explicitly writing code to use the extension.
>
Obviously more details in the other PRs for making the ptrauth_qualifier a feature or disabling -pedantic-errors when pointer auth is enabled: the problem here is that `-pedantic-errors` changes program semantics such that it results in ODR violations: if a declaration has properties that is determined by a `__has_extension` guard then `-pedantic-errors` changes the declaration semantics and creates an ODR violation (and in the case of ptrauth an ABI break).
I would argue that the bigger issue is this behavior from `__has_extension`: it seems that it presumes that all use of extensions will produce a warning, which gets turned into an error, so therefore anything used inside a `__has_extension(...) == true` block would always fail - but people can (and do) disable warnings all the time, so that assumption is incorrect. In addition to globally disabling warnings there is also `__extension__` which suppresses the warning locally and so also permits the use of an extension under `-pedantic-errors`.
The follow on problem here is that `__has_extension`'s behavior matches that of gcc, so I'm not sure it would be safe to change it.
https://github.com/llvm/llvm-project/pull/153104
More information about the cfe-commits
mailing list