[libcxx-commits] [libcxx] [libc++] Enable availability based on the compiler instead of __has_extension (PR #84065)
Aaron Ballman via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 7 08:32:26 PST 2024
AaronBallman wrote:
Okay, I'm changing my opinion based on this discussion -- thank you for the extra feedback! I found these points to be particularly compelling:
> I'm just not sure how to answer the second without having a million special cases.
> ```
> #pragma clang diagnostic ignored "-Wc11-extensions"
> _Atomic(int) v; // doesn't generate a diagnostic
> auto v = __has_extension(c_atomic); // Should this be 0 or 1?
> ```
and especially:
> and I think it's extremely confusing that warning flags would change the semantics of code, not just the diagnostics you get.
`-Wwrite-strings` changes the behavior of code in C and it's a terrible diagnostic in terms of usability as a result. `__has_extension` has similar (but less severe) impacts.
I still think all of the various feature testing macros should behave the same way, but now I'm leaning towards making them all behave more like `__has_cpp_attribute` instead of more like the current `__has_extension` behavior. That said, I'm still worried about breaking changes because `__has_extension` has been around for a *long* time, is documented to behave this way, and sees relatively heavy use. I think we'd have to find some way to warn users about the change in behavior, give a grace period for them to update their code (perhaps a fix-it or clang-tidy check could help?), and then later change behavior. I don't see that transition going quickly, either.
https://github.com/llvm/llvm-project/pull/84065
More information about the libcxx-commits
mailing list