[clang] [clang][bytecode]Fix-constant-eval-complex-discard (PR #177731)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 23 20:37:49 PST 2026
https://github.com/FYLGQ updated https://github.com/llvm/llvm-project/pull/177731
>From 128f0bf6edc86c0f1c1fd279466afccc95e1ebfc Mon Sep 17 00:00:00 2001
From: FYLGQ <799648409 at qq.com>
Date: Sat, 24 Jan 2026 10:58:51 +0800
Subject: [PATCH 1/2] fix-constant-eval-complex-discard
---
clang/lib/AST/ByteCode/Compiler.cpp | 3 ++-
clang/lib/AST/ByteCode/constant-eval-complex-discard.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 clang/lib/AST/ByteCode/constant-eval-complex-discard.c
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 272d08f5e455c..d864fdc5d7e6d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7406,7 +7406,8 @@ bool Compiler<Emitter>::emitComplexComparison(const Expr *LHS, const Expr *RHS,
const BinaryOperator *E) {
assert(E->isComparisonOp());
assert(!Initializing);
- assert(!DiscardResult);
+ if (DiscardResult)
+ return true;
PrimType ElemT;
bool LHSIsComplex;
diff --git a/clang/lib/AST/ByteCode/constant-eval-complex-discard.c b/clang/lib/AST/ByteCode/constant-eval-complex-discard.c
new file mode 100644
index 0000000000000..1d111fc049cc1
--- /dev/null
+++ b/clang/lib/AST/ByteCode/constant-eval-complex-discard.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -fexperimental-new-constant-interpreter %s
+
+void foo(void) {
+ // Complex comparison evaluated in a discarded context.
+ (void)(0 && (1i == 1i));
+}
>From b71ec175022ef25291c4bffb5bea65748730c430 Mon Sep 17 00:00:00 2001
From: FYLGQ <799648409 at qq.com>
Date: Sat, 24 Jan 2026 12:36:01 +0800
Subject: [PATCH 2/2] Move test file constant-eval-complex-discard.c to
clang/test/AST/ByteCode
---
clang/{lib => test}/AST/ByteCode/constant-eval-complex-discard.c | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename clang/{lib => test}/AST/ByteCode/constant-eval-complex-discard.c (100%)
diff --git a/clang/lib/AST/ByteCode/constant-eval-complex-discard.c b/clang/test/AST/ByteCode/constant-eval-complex-discard.c
similarity index 100%
rename from clang/lib/AST/ByteCode/constant-eval-complex-discard.c
rename to clang/test/AST/ByteCode/constant-eval-complex-discard.c
More information about the cfe-commits
mailing list