History

Code suppression fixes

See adjusted testcase, a lone break; in a do while loop was incorrectly disabling the exit test.

Michael Matz committed 9 years ago

Commit 7ad2cf81 parent 82942853 files · +40 −0Browse files

Unified · Split

3 files
  1. tccgen.c +2 −0
  2. tests/tests2/87_dead_code.c +33 −0
  3. tests/tests2/87_dead_code.expect +5 −0
tccgen.c+2−0
@@ -6088,6 +6088,8 @@ static void block(int *bsym, int *csym, int is_expr) · 6087 unmodified lines
6088 skip(TOK_WHILE);6088 skip(TOK_WHILE);
6089 skip('(');6089 skip('(');
6090 gsym(b);6090 gsym(b);
6091 if (b)
6092 nocode_wanted = saved_nocode_wanted;
6091 gexpr();6093 gexpr();
6092 c = gvtst(0, 0);6094 c = gvtst(0, 0);
6093 gsym_addr(c, d);6095 gsym_addr(c, d);
tests/tests2/87_dead_code.c+33−0
@@ -26,6 +26,36 @@ static void kb_wait_1(void) · 25 unmodified lines
26 timeout--;26 timeout--;
27 } while (timeout);27 } while (timeout);
28}28}
29
30static int global;
31
32static void foo(int i)
33{
34 global+=i;
35 printf ("g=%d\n", global);
36}
37
38static int check(void)
39{
40 printf ("check %d\n", global);
41 return 1;
42}
43
44static void dowhile(void)
45{
46 do {
47 foo(1);
48 if (global == 1) {
49 continue;
50 } else if (global == 2) {
51 continue;
52 }
53 /* The following break shouldn't disable the check() call,
54 as it's reachable by the continues above. */
55 break;
56 } while (check());
57}
58
29int main (void)59int main (void)
30{60{
31 int i = 1;61 int i = 1;
@@ -118,5 +148,8 @@ enterloop3: · 86 unmodified lines
118 printf ("error4\n");148 printf ("error4\n");
119 }149 }
120 }150 }
151
152 dowhile();
153
121 return 0;154 return 0;
122}155}
tests/tests2/87_dead_code.expect+5−0
@@ -16,3 +16,8 @@ once3 · 15 unmodified lines
16twice316twice3
17caseok17caseok
18caseok218caseok2
19g=1
20check 1
21g=2
22check 2
23g=3

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