Author: Timm Bäder
Date: 2023-07-26T07:46:04+02:00
New Revision: 2606545b0204e7d2d6434e78640d5732d9381837

URL: 
https://github.com/llvm/llvm-project/commit/2606545b0204e7d2d6434e78640d5732d9381837
DIFF: 
https://github.com/llvm/llvm-project/commit/2606545b0204e7d2d6434e78640d5732d9381837.diff

LOG: [clang][Interp] Fix ignoring conditional operators

Differential Revision: https://reviews.llvm.org/D148982

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/test/AST/Interp/literals.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 5e42cca6762104..ff40fd3da13f76 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -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>

diff  --git a/clang/test/AST/Interp/literals.cpp 
b/clang/test/AST/Interp/literals.cpp
index cf5e86658e3b38..25c40755c2d495 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -857,6 +857,9 @@ constexpr int ignoredExprs() {
 
   (void)5, (void)6;
 
+  1 ? 0 : 1; // expected-warning {{unused}} \
+             // ref-warning {{unused}}
+
   return 0;
 }
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to