Skip to content

Commit

Permalink
[clang][Interp] Fix ignoring conditional operators
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D148982
  • Loading branch information
tbaederr committed Jul 26, 2023
1 parent aed9646 commit 2606545
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Expand Up @@ -595,8 +595,9 @@ bool ByteCodeExprGen<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitAbstractConditionalOperator(
const AbstractConditionalOperator *E) {
return this->visitConditional(
E, [this](const Expr *E) { return this->visit(E); });
return this->visitConditional(E, [this](const Expr *E) {
return DiscardResult ? this->discard(E) : this->visit(E);
});
}

template <class Emitter>
Expand Down
3 changes: 3 additions & 0 deletions clang/test/AST/Interp/literals.cpp
Expand Up @@ -857,6 +857,9 @@ constexpr int ignoredExprs() {

(void)5, (void)6;

1 ? 0 : 1; // expected-warning {{unused}} \
// ref-warning {{unused}}

return 0;
}

Expand Down

0 comments on commit 2606545

Please sign in to comment.