summaryrefslogtreecommitdiff
path: root/test/Sema/struct-decl.c
blob: 055f14bf4dc60b907b9bbd1358254f2f1f9a467f (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
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR3459
struct bar {
  char n[1];
};

struct foo {
  char name[(int)&((struct bar *)0)->n];
  char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{'name2' declared as an array with a negative size}}
};

// PR3430
struct s {
  struct st {
    int v;
  } *ts;
};

struct st;

int foo() {
  struct st *f;
  return f->v + f[0].v;
}

// PR3642, PR3671
struct pppoe_tag {
 short tag_type;
 char tag_data[];
};
struct datatag {
  struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
  char data;
};


// PR4092
struct s0 {
  char a;  // expected-note {{previous declaration is here}}
  char a;  // expected-error {{duplicate member 'a'}}
};

struct s0 f0(void) {}

// <rdar://problem/8177927> - This previously triggered an assertion failure.
struct x0 {
  unsigned int x1;
};

// rdar://problem/9150338
static struct test1 { // expected-warning {{'static' ignored on this declaration}}
  int x;
};
const struct test2 { // expected-warning {{'const' ignored on this declaration}}
  int x;
};
inline struct test3 { // expected-error {{'inline' can only appear on functions}}
  int x;
};

struct hiding_1 {};
struct hiding_2 {};
void test_hiding() {
  struct hiding_1 *hiding_1();
  extern struct hiding_2 *hiding_2;
  struct hiding_1 *p = hiding_1();
  struct hiding_2 *q = hiding_2;
}

struct PreserveAttributes {};
typedef struct __attribute__((noreturn)) PreserveAttributes PreserveAttributes_t; // expected-warning {{'noreturn' attribute only applies to functions and methods}}