[clang] [clang][bytecode] Disable DiscardResult in visitBool() (PR #188916)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 27 00:16:33 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
It's a visit* function, so we shouldn't discard the result.
---
Full diff: https://github.com/llvm/llvm-project/pull/188916.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3)
- (modified) clang/test/AST/ByteCode/c.c (+3)
``````````diff
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}}
``````````
</details>
https://github.com/llvm/llvm-project/pull/188916
More information about the cfe-commits
mailing list