Skip to content

Commit

Permalink
[clang][Interp] Fix ignoring Integral- and IntegralToBoolean casts
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D154474
  • Loading branch information
tbaederr committed Aug 1, 2023
1 parent f5edeb2 commit 21aa8a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {

case CK_IntegralToBoolean:
case CK_IntegralCast: {
if (DiscardResult)
return this->discard(SubExpr);
std::optional<PrimType> FromT = classify(SubExpr->getType());
std::optional<PrimType> ToT = classify(CE->getType());
if (!FromT || !ToT)
Expand Down
3 changes: 3 additions & 0 deletions clang/test/AST/Interp/literals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ namespace DiscardExprs {
sizeof(int);
alignof(int);

(short)5;
(bool)1;

return 0;
}
static_assert(ignoredExprs() == 0, "");
Expand Down

0 comments on commit 21aa8a2

Please sign in to comment.