summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/anon-struct-9.c
blob: d223490457263806c99c3e8e931762100d882019 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* Test for diagnostics for duplicate member names in anonymous
   structures and unions.  PR 4784.  */
/* { dg-do compile } */
/* { dg-options "" } */

struct s1
{
  int x;
  struct
  {
    int x; /* { dg-error "duplicate member" } */
  };
};

struct s2
{
  struct
  {
    int a;
    struct
    {
      int b;
    };
  };
  struct
  {
    int b; /* { dg-error "duplicate member" } */
  };
};

struct s3
{
  struct
  {
    int a;
    struct
    {
      int b;
    };
  };
  struct
  {
    int b; /* { dg-error "duplicate member" } */
    int c;
  };
};

struct s4
{
  int x;
  struct
  {
    int x;
  } y;
};

union u1
{
  int x;
  union
  {
    int x; /* { dg-error "duplicate member" } */
  };
};

union u2
{
  union
  {
    int a;
    union
    {
      int b;
    };
  };
  union
  {
    int b; /* { dg-error "duplicate member" } */
  };
};

union u3
{
  union
  {
    int a;
    union
    {
      int b;
    };
  };
  union
  {
    int b; /* { dg-error "duplicate member" } */
    int c;
  };
};

union u4
{
  int x;
  union
  {
    int x;
  } y;
};

#define D10(x) int x##0; int x##1; int x##2; int x##3; int x##4; int x##5; int x##6; int x##7; int x##8; int x##9;
#define D100(x) D10(x##0) D10(x##1) D10(x##2) D10(x##3) D10(x##4) D10(x##5) D10(x##6) D10(x##7) D10(x##8) D10(x##9)

#define S10(x) struct { D100(x##0) }; struct { D100(x##1) }; struct { D100(x##2) }; struct { D100(x##3) }; struct { D100(x##4) }; struct { D100(x##5) }; struct { D100(x##6) }; struct { D100(x##7) }; struct { D100(x##8) }; struct { D100(x##9) };

struct sbig
{
  S10(a)
  S10(b)
  S10(c)
  S10(d)
  S10(e)
  S10(f)
  S10(g)
  S10(h)
  S10(j)
  S10(k)
  struct
  {
    int a123; /* { dg-error "duplicate member" } */
  };
};