https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/188916

It's a visit* function, so we shouldn't discard the result.

>From bca8e39231928e971619b9330377031df8ae1309 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Fri, 27 Mar 2026 08:13:11 +0100
Subject: [PATCH] [clang][bytecode] Disable DiscardResult in visitBool()

It's a visit* function, so we shouldn't discard the result.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 3 +++
 clang/test/AST/ByteCode/c.c         | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c38eb0fa93877..096a0cae31556 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4630,6 +4630,9 @@ template <class Emitter> bool 
Compiler<Emitter>::visitAsLValue(const Expr *E) {
 }
 
 template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
+  OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/false,
+                             /*NewInitializing=*/false, /*ToLValue=*/ToLValue);
+
   OptPrimType T = classify(E->getType());
   if (!T) {
     // Convert complex values to bool.
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 550a51002b60f..78820d04ba3f5 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -446,3 +446,6 @@ void strcpyDouble(void) {
   const double test_buf[] = {'4', '2'};
   __builtin_strcpy(buf, test_buf + 1); // all-error {{incompatible pointer 
types}}
 }
+
+int *iptr;
+void ignoredConditional(void) { *iptr = (((_Complex double)1.0 ? 2 : 3), a); } 
// all-warning {{left operand of comma operator has no effect}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to