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