blob: 2c0945f9f86bde6df8125f0fd7fadd55670ae153 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Nuno Lopesf2319982009-02-02 15:00:55 +00002// PR3459
3struct bar {
4 char n[1];
5};
6
7struct foo {
8 char name[(int)&((struct bar *)0)->n];
Zhongxing Xu6beb1652009-02-19 08:45:23 +00009 char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
Nuno Lopesf2319982009-02-02 15:00:55 +000010};
Douglas Gregor1931b442009-02-03 00:34:39 +000011
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}
Eli Friedman85c35152009-02-22 00:20:44 +000025
Douglas Gregore4f3e062009-03-06 23:41:27 +000026// PR3642, PR3671
Eli Friedman85c35152009-02-22 00:20:44 +000027struct pppoe_tag {
28 short tag_type;
29 char tag_data[];
30};
31struct datatag {
Chris Lattner740782a2009-04-25 18:52:45 +000032 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}}
Eli Friedman85c35152009-02-22 00:20:44 +000033 char data;
34};
35
Chris Lattner65e6a092009-04-29 05:12:23 +000036
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) {}