summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c1x-anon-struct-2.c
blob: cb8043117d5d13c566838fc0fb5b9aa706e740a6 (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
/* Test for anonymous structures and unions in C1X.  Test for invalid
   cases.  */
/* { dg-do compile } */
/* { dg-options "-std=c1x -pedantic-errors" } */

typedef struct s0
{
  int i;
} s0;

struct s1
{
  int a;
  struct s0; /* { dg-error "declaration does not declare anything" } */
};

struct s2
{
  int a;
  s0; /* { dg-error "declaration does not declare anything" } */
};

struct s3
{
  struct
  {
    int i;
  };
  struct
  {
    int i; /* { dg-error "duplicate member" } */
  };
};

struct s4
{
  int a;
  struct s
  {
    int i;
  }; /* { dg-error "declaration does not declare anything" } */
};

struct s5
{
  struct
  {
    int i;
  } a;
  int b;
} x;

void
f (void)
{
  x.i = 0; /* { dg-error "has no member" } */
}