Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug-751703.c
1 /* bug-751703.c
2
3   Make sure extern within local scope binds to global
4   scope and is not optimized inappropriately.
5  */
6
7 #include "testfwk.h"
8
9 int x = 1;
10 int y = 2;
11 int z = 0;
12
13 static void
14 addxy(void)
15 {
16   extern int x, y, z;
17   z = x+y;
18
19
20 static void
21 times10x(void)
22 {
23   unsigned char x;
24   
25   z = 0;
26   for (x=0; x<10; x++)
27     {
28       extern int x; /* bind to the global x */
29       z += x;
30     }
31 }
32
33 static void
34 testExternDeadCode(void)
35 {
36   ASSERT(z == 0);
37   addxy();
38   ASSERT(z == 3);
39   times10x();
40   ASSERT(z == 10);
41 }