opnsense-src/test/Sema/struct-decl.c

44 lines
787 B
C
Raw Normal View History

2010-01-01 05:34:51 -05:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-06-02 13:58:47 -04:00
// PR3459
struct bar {
2009-10-14 14:03:49 -04:00
char n[1];
2009-06-02 13:58:47 -04:00
};
struct foo {
2009-10-14 14:03:49 -04:00
char name[(int)&((struct bar *)0)->n];
char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
2009-06-02 13:58:47 -04:00
};
// PR3430
struct s {
2009-10-14 14:03:49 -04:00
struct st {
int v;
} *ts;
2009-06-02 13:58:47 -04:00
};
struct st;
int foo() {
2009-10-14 14:03:49 -04:00
struct st *f;
return f->v + f[0].v;
2009-06-02 13:58:47 -04:00
}
// PR3642, PR3671
struct pppoe_tag {
short tag_type;
char tag_data[];
};
struct datatag {
2009-10-14 14:03:49 -04:00
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;
2009-06-02 13:58:47 -04:00
};
// PR4092
struct s0 {
char a; // expected-note {{previous declaration is here}}
char a; // expected-error {{duplicate member 'a'}}
};
struct s0 f0(void) {}