summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wswitch-unreachable-1.c
blob: 2e5c99bce3c578426fcefb44fa864152f7d843e7 (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
/* PR c/49859 */
/* { dg-do compile } */
/* { dg-options "-Wswitch-unreachable" } */

extern void foo (int);
extern int j;

void
fn0 (int i)
{
  switch (i)
    {
    int t = 10; /* { dg-warning "statement will never be executed" } */
    default:
      foo (t);
    }

  switch (i)
    { /* { dg-warning "statement will never be executed" } */
      int A[i];
      default: /* { dg-error "switch jumps into scope" } */
	break;
    }

  switch (i)
    default:
      j = sizeof (struct { int i; });

  switch (i)
    {
      int A[3];
      default:
	break;
    }
}