Skip to content

Commit c8a06f8

Browse files
tbaederrgoogle-yfyang
authored andcommitted
[clang][bytecode] Don't get the expr without emitting a diagnostic (llvm#141953)
1 parent d7f4d09 commit c8a06f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/AST/ByteCode/Interp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,16 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS,
200200

201201
if constexpr (Dir == ShiftDir::Left) {
202202
if (LHS.isSigned() && !S.getLangOpts().CPlusPlus20) {
203-
const Expr *E = S.Current->getExpr(OpPC);
204203
// C++11 [expr.shift]p2: A signed left shift must have a non-negative
205204
// operand, and must not overflow the corresponding unsigned type.
206205
if (LHS.isNegative()) {
206+
const Expr *E = S.Current->getExpr(OpPC);
207207
S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS.toAPSInt();
208208
if (!S.noteUndefinedBehavior())
209209
return false;
210210
} else if (LHS.toUnsigned().countLeadingZeros() <
211211
static_cast<unsigned>(RHS)) {
212+
const Expr *E = S.Current->getExpr(OpPC);
212213
S.CCEDiag(E, diag::note_constexpr_lshift_discards);
213214
if (!S.noteUndefinedBehavior())
214215
return false;

0 commit comments

Comments
 (0)