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