History

Fix more jumpopts (in ternary op)

the code in expr_cond save nocode_wanted around some parts of expression evaluation, but at the wrong spots. If the evaluation of the condition itself (e.g. in the testcase the first whole ternary expression) resulted in CODE_OFF, then that was saved, and restored before return, even if in-between codegen would have CODE_ON'ed already. Thus the whole CODE_OFF state bled out to outside the expression evaluation and also disabled the whole if-block. Found by yarpgen v1 (seed 64).

Michael Matz committed 3 years ago

Commit 2cf3a6e1 parent ec818773 files · +18 −5Browse files

Showing the changes to tests (2 of 3 files). Show all

Unified · Split

2 files
  1. tests/tests2/33_ternary_op.c +13 −0
  2. tests/tests2/33_ternary_op.expect +1 −0
tests/tests2/33_ternary_op.c+13−0
@@ -39,6 +39,17 @@ static int getme(struct condstruct* s, int i) · 38 unmodified lines
3939 return i1 + i2 + i3 + i4;
4040 }
4141
42+int someglobal;
43+
44+void constantcond(void)
45+{
46+ /* This was broken by 8227db3a2, it saved/restored the CODE_OFF state
47+ during the expression and that bled out to the outer one disabling
48+ codegen for if-body. */
49+ if (( (someglobal ? 0 : 0) ? 8 : 9))
50+ printf("okay\n");
51+}
52+
4253 int main()
4354 {
4455 int Count;
@@ -73,6 +84,8 @@ int main() · 28 unmodified lines
7384 //0 ? a : 0.0;
7485 }
7586
87+ constantcond();
88+
7689
7790 return 0;
7891 }
tests/tests2/33_ternary_op.expect+1−0
@@ -10,3 +10,4 @@ · 9 unmodified lines
1010 24
1111 27
1212 152
13+okay

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t