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