[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode
Dávid Bolvanský via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 30 15:29:30 PDT 2019
xbolva00 marked 2 inline comments as done.
xbolva00 added inline comments.
================
Comment at: clang/lib/AST/ExprConstant.cpp:10595
+ const auto *Callee = Info.CurrentCall->getCallee();
+ if (Info.InConstantContext && !Info.CheckingPotentialConstantExpression &&
+ (Info.CallStackDepth == 1 ||
----------------
!Info.CheckingPotentialConstantExpression
Basically just to silence test case:
namespace std {
constexpr bool is_constant_evaluated() noexcept {
return __builtin_is_constant_evaluated();
}
}
In real world code, this will not warn, since call's loc is in system header. Leave it?
================
Comment at: clang/lib/AST/ExprConstant.cpp:10600
+ Callee->getIdentifier()->isStr("is_constant_evaluated")))) {
+ if (Info.EvalStatus.Diag)
+ Info.report((Info.CallStackDepth == 1) ? E->getExprLoc()
----------------
Without this condition, it warns 3 times for
if constexpr (std::is_constant_evaluated() == false)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69518/new/
https://reviews.llvm.org/D69518
More information about the cfe-commits
mailing list