mirror of
https://github.com/TinyCC/tinycc.git
synced 2026-05-12 20:05:45 +00:00
tccgen: fix void expression side effect regression
From 7e01b20362
reduced from an app that builds/runs with gcc or clang.
This commit is contained in:
1
tccgen.c
1
tccgen.c
@@ -3278,7 +3278,6 @@ again:
|
||||
dbt_bt = dbt & VT_BTYPE;
|
||||
sbt_bt = sbt & VT_BTYPE;
|
||||
if (dbt_bt == VT_VOID) {
|
||||
vtop->r = vtop->r2 = VT_CONST;
|
||||
goto done;
|
||||
}
|
||||
if (sbt_bt == VT_VOID) {
|
||||
|
||||
17
tests/tests2/143_void_expr.c
Normal file
17
tests/tests2/143_void_expr.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
static void f(int x)
|
||||
{
|
||||
printf("f(%d)\n", x);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int count = 0, i = 0;
|
||||
for (; i < 3; ++i) {
|
||||
printf("%d\n", i);
|
||||
(void)(i || (f(i), ++count));
|
||||
}
|
||||
printf("count %d\n", count);
|
||||
return count == 1 ? 0 : 1;
|
||||
}
|
||||
5
tests/tests2/143_void_expr.expect
Normal file
5
tests/tests2/143_void_expr.expect
Normal file
@@ -0,0 +1,5 @@
|
||||
0
|
||||
f(0)
|
||||
1
|
||||
2
|
||||
count 1
|
||||
Reference in New Issue
Block a user