summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/20030309-1.c
blob: 2431bc1b52f307d2febac2aedfe7a897786a87e9 (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
/* { dg-do link } */
/* { dg-options "-O2" } */

struct A0 { int x; };
struct A1 { int x; int y[1]; };
struct A2 { int x; int y[2]; };
struct A3 { int x; int y[3]; };
struct A4 { int x; int y[4]; };

void *s;
int u;

int
main (void)
{
  int x;
  void *t = s;

  switch (u)
    {
    case 0:
      x = ((struct A0 *) t)->x;
      break;
    case 1:
      x = ((struct A1 *) t)->x;
      break;
    case 2:
      x = ((struct A2 *) t)->x;
      break;
    case 3:
      x = ((struct A3 *) t)->x;
      break;
    case 4:
      x = ((struct A4 *) t)->x;
      break;
    default:
      x = 0;
      break;
    }

  return x;
}