https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/156180
Our comparison ops always return bool, and we do the pop before the conversion to in in C. Fixes #156178 >From a8c9f87454c4ecb382e465b4cfc6ccd6a7787130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sat, 30 Aug 2025 15:28:38 +0200 Subject: [PATCH] [clang][bytecode] Fix ignoring comparisons in C Our comparison ops always return bool, and we do the pop before the conversion to in in C. Fixes #156178 --- clang/lib/AST/ByteCode/Compiler.cpp | 2 +- clang/test/AST/ByteCode/c.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
