-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][bytecode] Fix ignoring comparisons in C #156180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Our comparison ops always return bool, and we do the pop before the conversion to in in C. Fixes llvm#156178
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesOur comparison ops always return bool, and we do the pop before the conversion to in in C. Fixes #156178 Full diff: https://github.com/llvm/llvm-project/pull/156180.diff 2 Files Affected:
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}}
+}
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/20801 Here is the relevant piece of the build log for the reference |
Our comparison ops always return bool, and we do the pop before the conversion to in in C.
Fixes #156178