[libcxx-commits] [PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated
Christopher Di Bella via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 11 10:18:31 PDT 2023
cjdb added inline comments.
================
Comment at: clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp:38
constexpr int fn5() {
- if constexpr (__builtin_is_constant_evaluated()) // expected-warning {{'__builtin_is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
+ if constexpr (__builtin_is_constant_evaluated()) // expected-warning {{'__builtin_is_constant_evaluated' will always evaluate to true in this context}}
return 0;
----------------
This should also generate a fix-it hint, since we can automate the fix.
================
Comment at: clang/test/SemaCXX/warn-tautological-meta-constant.cpp:18
+ } else {
+ if constexpr (std::is_constant_evaluated()) { // expected-warning {{always evaluate to true}}
+ return 0;
----------------
I'm not a fan of this diagnostic text: it doesn't offer insight into what's gone wrong or provide actionable feedback on how to fix the code.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155064/new/
https://reviews.llvm.org/D155064
More information about the libcxx-commits
mailing list