[clang] [clang][bytecode] Disable DiscardResult in visitBool() (PR #188916)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 27 00:15:58 PDT 2026
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?= <tbaeder at redhat.com>
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}}
More information about the cfe-commits
mailing list