[Clang] Fix for Tighten restrictions on enum out of range diagnostic

Ok it looks like this is a bit more subtle, I broke the llvm-test-suite file
paq8p.cpp again. We need both conditions to be true Info.EvalMode ==
EvalInfo::EM_ConstantExpression && Info.InConstantContext. We need to be in a
context that requires a constant value but also in a constant expression context.

Differential Revision: https://reviews.llvm.org/D131704
This commit is contained in:
Shafik Yaghmour 2022-08-11 15:32:35 -07:00
parent 28d0c0c2c8
commit 106774515b
1 changed files with 1 additions and 0 deletions

View File

@ -13534,6 +13534,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
}
if (Info.Ctx.getLangOpts().CPlusPlus && Info.InConstantContext &&
Info.EvalMode == EvalInfo::EM_ConstantExpression &&
DestType->isEnumeralType()) {
const EnumType *ET = dyn_cast<EnumType>(DestType.getCanonicalType());
const EnumDecl *ED = ET->getDecl();