Author: Shafik Yaghmour Date: 2022-08-11T15:34:58-07:00 New Revision: 106774515b77d55edeab6e80555c410efc1f586a
URL: https://github.com/llvm/llvm-project/commit/106774515b77d55edeab6e80555c410efc1f586a DIFF: https://github.com/llvm/llvm-project/commit/106774515b77d55edeab6e80555c410efc1f586a.diff LOG: [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 Added: Modified: clang/lib/AST/ExprConstant.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 67a1fa4318661..f8de0f28d1840 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -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(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits