diff options
author | Shafik Yaghmour <shafik.yaghmour@intel.com> | 2022-07-27 15:31:41 -0700 |
---|---|---|
committer | Shafik Yaghmour <shafik.yaghmour@intel.com> | 2022-07-27 15:31:41 -0700 |
commit | 28cd7f86ed0e94ea3ae56a49ba85f0ccb7b51dd4 (patch) | |
tree | c984360a6ebd81c44c3dd463e2badf20189b8da5 /clang/lib/AST/ExprConstant.cpp | |
parent | ecda408178fc6486ea568263cdda6624f5bcb8c7 (diff) | |
download | llvm-28cd7f86ed0e94ea3ae56a49ba85f0ccb7b51dd4.zip llvm-28cd7f86ed0e94ea3ae56a49ba85f0ccb7b51dd4.tar.gz llvm-28cd7f86ed0e94ea3ae56a49ba85f0ccb7b51dd4.tar.bz2 |
Revert "[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values"
This reverts commit a3710589f285de0bb22ff92b1fc24df9411e986f.
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 0f15859..9d92c84 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -13519,34 +13519,6 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) { return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType); } - if (const EnumType *ET = dyn_cast<EnumType>(DestType)) { - const EnumDecl *ED = ET->getDecl(); - // Check that the value is within the range of the enumeration values. - // - // This corressponds to [expr.static.cast]p10 which says: - // A value of integral or enumeration type can be explicitly converted - // to a complete enumeration type ... If the enumeration type does not - // have a fixed underlying type, the value is unchanged if the original - // value is within the range of the enumeration values ([dcl.enum]), and - // otherwise, the behavior is undefined. - // - // This was resolved as part of DR2338 which has CD5 status. - if (!ED->isFixed()) { - llvm::APInt Min; - llvm::APInt Max; - - ED->getValueRange(Max, Min); - - if (ED->getNumNegativeBits() && - (Max.sle(Result.getInt()) || Min.sgt(Result.getInt()))) - CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range) - << Result.getInt() << Min.getSExtValue() << Max.getSExtValue(); - else if (!ED->getNumNegativeBits() && Max.ule(Result.getInt())) - CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range) - << Result.getInt() << Min.getZExtValue() << Max.getZExtValue(); - } - } - return Success(HandleIntToIntCast(Info, E, DestType, SrcType, Result.getInt()), E); } |