aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vla-stexp-8.c
blob: 5b475eb6cf2061ba2edbe7f2e51995c444f84267 (plain)
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
42
43
44
45
46
47
/* PR29970, PR91038 */
/* { dg-do compile } */
/* { dg-options "-O2 -Wunused-variable" } */


int foo0(void)
{
	int c = *(*(*({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }) + 5) + 5);
	return c;
}

int foo1(void)
{
	int c = *(5 + *(5 + *({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; })));
	return c;
}

int bar2(void)
{
	int c = (*({ int n = 10; struct { int y[n]; int z; }* x = __builtin_malloc(sizeof *x); x; })).z;
	return c;
}

int bar3(void)
{
	int n = 2;	/* { dg-warning "unused variable" } */
	int c = (*({ int n = 3; 	/* { dg-warning "unused variable" } */
		({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); }))[5][5];
	return c;
}

int bar3b(void)
{
	int n = 2;	/* { dg-warning "unused variable" } */
	int c = (*({ int n = 3; 	/* { dg-warning "unused variable" } */
		({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); }))[0][0];
	return c;
}

int bar4(void)
{
	int n = 2;	/* { dg-warning "unused variable" } */
	int c = *(5 + *( 5 + *({ int n = 3;	/* { dg-warning "unused variable" } */
		({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); })));
	return c;
}