[clang] 1bbac05 - [clang][bytecode] Fix ignoring comparisons in C (#156180)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 30 08:41:12 PDT 2025
Author: Timm Baeder
Date: 2025-08-30T17:41:08+02:00
New Revision: 1bbac057f6de10db683e70c8c966809ad576b93e
URL: https://github.com/llvm/llvm-project/commit/1bbac057f6de10db683e70c8c966809ad576b93e
DIFF: https://github.com/llvm/llvm-project/commit/1bbac057f6de10db683e70c8c966809ad576b93e.diff
LOG: [clang][bytecode] Fix ignoring comparisons in C (#156180)
Our comparison ops always return bool, and we do the pop before the
conversion to in in C.
Fixes #156178
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/c.c
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index c314f0a132196..56552f3969216 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -942,7 +942,7 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
if (!Result)
return false;
if (DiscardResult)
- return this->emitPop(*T, BO);
+ return this->emitPopBool(BO);
if (T != PT_Bool)
return this->emitCast(PT_Bool, *T, BO);
return true;
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 05af00c040f45..b6d2a69271afb 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -362,3 +362,9 @@ void bar() { // pedantic-warning {{a function declaration without a prototype}}
int x;
x = foo(); // all-warning {{too few arguments}}
}
+
+int *_b = &a;
+void discardedCmp(void)
+{
+ (*_b) = ((&a == &a) , a); // all-warning {{left operand of comma operator has no effect}}
+}
More information about the cfe-commits
mailing list