shafik created this revision. shafik added reviewers: erichkeane, aaron.ballman, zatrazz. Herald added a project: All. shafik requested review of this revision.
In D131307 <https://reviews.llvm.org/D131307> we allowed the diagnostic to be turned into a warning for a transition period. This had the side effect of triggering the warning in contexts not required to be constant expression. This change will restrict the diagnostic to constant expression contexts. This should reduce the fallout of this diagnostic. https://reviews.llvm.org/D131528 Files: clang/lib/AST/ExprConstant.cpp Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -13533,7 +13533,9 @@ return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType); } - if (Info.Ctx.getLangOpts().CPlusPlus && DestType->isEnumeralType()) { + if (Info.Ctx.getLangOpts().CPlusPlus && + Info.EvalMode == EvalInfo::EM_ConstantExpression && + DestType->isEnumeralType()) { const EnumType *ET = dyn_cast<EnumType>(DestType.getCanonicalType()); const EnumDecl *ED = ET->getDecl(); // Check that the value is within the range of the enumeration values.
Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -13533,7 +13533,9 @@ return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType); } - if (Info.Ctx.getLangOpts().CPlusPlus && DestType->isEnumeralType()) { + if (Info.Ctx.getLangOpts().CPlusPlus && + Info.EvalMode == EvalInfo::EM_ConstantExpression && + DestType->isEnumeralType()) { const EnumType *ET = dyn_cast<EnumType>(DestType.getCanonicalType()); const EnumDecl *ED = ET->getDecl(); // Check that the value is within the range of the enumeration values.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits