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
60886088 skip(TOK_WHILE);
60896089 skip('(');
60906090 gsym(b);
6091+ if (b)
6092+ nocode_wanted = saved_nocode_wanted;
60916093 gexpr();
60926094 c = gvtst(0, 0);
60936095 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
2626 timeout--;
2727 } while (timeout);
2828 }
29+
30+static int global;
31+
32+static void foo(int i)
33+{
34+ global+=i;
35+ printf ("g=%d\n", global);
36+}
37+
38+static int check(void)
39+{
40+ printf ("check %d\n", global);
41+ return 1;
42+}
43+
44+static 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+
2959 int main (void)
3060 {
3161 int i = 1;
@@ -118,5 +148,8 @@ enterloop3: · 86 unmodified lines
118148 printf ("error4\n");
119149 }
120150 }
151+
152+ dowhile();
153+
121154 return 0;
122155 }
tests/tests2/87_dead_code.expect+5−0
@@ -16,3 +16,8 @@ once3 · 15 unmodified lines
1616 twice3
1717 caseok
1818 caseok2
19+g=1
20+check 1
21+g=2
22+check 2
23+g=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