1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li // PR3459 3*67e74705SXin Li struct bar { 4*67e74705SXin Li char n[1]; 5*67e74705SXin Li }; 6*67e74705SXin Li 7*67e74705SXin Li struct foo { 8*67e74705SXin Li char name[(int)&((struct bar *)0)->n]; 9*67e74705SXin Li char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{'name2' declared as an array with a negative size}} 10*67e74705SXin Li }; 11*67e74705SXin Li 12*67e74705SXin Li // PR3430 13*67e74705SXin Li struct s { 14*67e74705SXin Li struct st { 15*67e74705SXin Li int v; 16*67e74705SXin Li } *ts; 17*67e74705SXin Li }; 18*67e74705SXin Li 19*67e74705SXin Li struct st; 20*67e74705SXin Li foo()21*67e74705SXin Liint foo() { 22*67e74705SXin Li struct st *f; 23*67e74705SXin Li return f->v + f[0].v; 24*67e74705SXin Li } 25*67e74705SXin Li 26*67e74705SXin Li // PR3642, PR3671 27*67e74705SXin Li struct pppoe_tag { 28*67e74705SXin Li short tag_type; 29*67e74705SXin Li char tag_data[]; 30*67e74705SXin Li }; 31*67e74705SXin Li struct datatag { 32*67e74705SXin Li 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*67e74705SXin Li char data; 34*67e74705SXin Li }; 35*67e74705SXin Li 36*67e74705SXin Li 37*67e74705SXin Li // PR4092 38*67e74705SXin Li struct s0 { 39*67e74705SXin Li char a; // expected-note {{previous declaration is here}} 40*67e74705SXin Li char a; // expected-error {{duplicate member 'a'}} 41*67e74705SXin Li }; 42*67e74705SXin Li f0(void)43*67e74705SXin Listruct s0 f0(void) {} 44*67e74705SXin Li 45*67e74705SXin Li // <rdar://problem/8177927> - This previously triggered an assertion failure. 46*67e74705SXin Li struct x0 { 47*67e74705SXin Li unsigned int x1; 48*67e74705SXin Li }; 49*67e74705SXin Li 50*67e74705SXin Li // rdar://problem/9150338 51*67e74705SXin Li static struct test1 { // expected-warning {{'static' ignored on this declaration}} 52*67e74705SXin Li int x; 53*67e74705SXin Li }; 54*67e74705SXin Li const struct test2 { // expected-warning {{'const' ignored on this declaration}} 55*67e74705SXin Li int x; 56*67e74705SXin Li }; 57*67e74705SXin Li inline struct test3 { // expected-error {{'inline' can only appear on functions}} 58*67e74705SXin Li int x; 59*67e74705SXin Li }; 60*67e74705SXin Li 61*67e74705SXin Li struct hiding_1 {}; 62*67e74705SXin Li struct hiding_2 {}; test_hiding()63*67e74705SXin Livoid test_hiding() { 64*67e74705SXin Li struct hiding_1 *hiding_1(); 65*67e74705SXin Li extern struct hiding_2 *hiding_2; 66*67e74705SXin Li struct hiding_1 *p = hiding_1(); 67*67e74705SXin Li struct hiding_2 *q = hiding_2; 68*67e74705SXin Li } 69*67e74705SXin Li 70*67e74705SXin Li struct PreserveAttributes {}; 71*67e74705SXin Li typedef struct __attribute__((noreturn)) PreserveAttributes PreserveAttributes_t; // expected-warning {{'noreturn' attribute only applies to functions and methods}} 72