Skip to content

Commit 1bbac05

Browse files
authored
[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
1 parent 62ff9ac commit 1bbac05

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
942942
if (!Result)
943943
return false;
944944
if (DiscardResult)
945-
return this->emitPop(*T, BO);
945+
return this->emitPopBool(BO);
946946
if (T != PT_Bool)
947947
return this->emitCast(PT_Bool, *T, BO);
948948
return true;

clang/test/AST/ByteCode/c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,9 @@ void bar() { // pedantic-warning {{a function declaration without a prototype}}
362362
int x;
363363
x = foo(); // all-warning {{too few arguments}}
364364
}
365+
366+
int *_b = &a;
367+
void discardedCmp(void)
368+
{
369+
(*_b) = ((&a == &a) , a); // all-warning {{left operand of comma operator has no effect}}
370+
}

0 commit comments

Comments
 (0)