[Clang] Diagnose undefined behavior in a constant expression while evaluating a compo...
authorShafik Yaghmour <shafik.yaghmour@intel.com>
Thu, 12 Jan 2023 16:02:00 +0000 (08:02 -0800)
committerShafik Yaghmour <shafik.yaghmour@intel.com>
Thu, 12 Jan 2023 16:04:04 +0000 (08:04 -0800)
commita0138390dd2ac2130c9f76e6778d6e45e4dc5526
treef495b665bd382aaca83a3ed100524862d9537c54
parented001018a02b3d8da699317cad7f7727d126f01d
[Clang] Diagnose undefined behavior in a constant expression while evaluating a compound assignment with remainder as operand

Currently we don't diagnose overflow in a constant expression for the case of
compound assignment with remainder as a operand.

In handleIntIntBinOp the arguments LHS and Result can be the same source but in
the check for remainder in this function we assigned to Result before checking
for overflow. In all the other operations the check is done before Result is
assigned to.

Differential Revision: https://reviews.llvm.org/D140455
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp