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
39 return i1 + i2 + i3 + i4;39 return i1 + i2 + i3 + i4;
40}40}
41 41
42int someglobal;
43
44void 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
42int main()53int main()
43{54{
44 int Count;55 int Count;
@@ -73,6 +84,8 @@ int main() · 28 unmodified lines
73 //0 ? a : 0.0;84 //0 ? a : 0.0;
74 }85 }
75 86
87 constantcond();
88
76 89
77 return 0;90 return 0;
78}91}
tests/tests2/33_ternary_op.expect+1−0
@@ -10,3 +10,4 @@ · 9 unmodified lines
10241024
11271127
1215212152
13okay

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