struct-decl.c revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// PR3459
3struct bar {
4  char n[1];
5};
6
7struct foo {
8  char name[(int)&((struct bar *)0)->n];
9  char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
10};
11
12// PR3430
13struct s {
14  struct st {
15    int v;
16  } *ts;
17};
18
19struct st;
20
21int foo() {
22  struct st *f;
23  return f->v + f[0].v;
24}
25
26// PR3642, PR3671
27struct pppoe_tag {
28 short tag_type;
29 char tag_data[];
30};
31struct datatag {
32  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}}
33  char data;
34};
35
36
37// PR4092
38struct s0 {
39  char a;  // expected-note {{previous declaration is here}}
40  char a;  // expected-error {{duplicate member 'a'}}
41};
42
43struct s0 f0(void) {}
44