Shih-wei Liao | ea28516 | 2010-06-04 12:34:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | struct S0; |
| 4 | struct S1; |
| 5 | struct S2; |
| 6 | struct S3; |
| 7 | struct S4; |
| 8 | struct S5; |
| 9 | struct S6; |
| 10 | |
| 11 | struct S0 { int x; }; |
| 12 | |
| 13 | void f0() { |
| 14 | typedef struct S1 { int x; } S1_typedef; |
| 15 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 16 | (void)((struct S2 { int x; }*)0); // expected-error{{cannot be defined}} |
Shih-wei Liao | ea28516 | 2010-06-04 12:34:56 -0700 | [diff] [blame] | 17 | |
| 18 | struct S3 { int x; } s3; |
| 19 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 20 | (void)static_cast<struct S4 { int x; } *>(0); // expected-error{{cannot be defined}} |
Shih-wei Liao | ea28516 | 2010-06-04 12:34:56 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | struct S5 { int x; } f1() { return S5(); } // expected-error{{result type}} |
| 24 | |
| 25 | void f2(struct S6 { int x; } p); // expected-error{{parameter type}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 26 | |
| 27 | struct pr19018 { |
| 28 | short foo6 (enum bar0 {qq} bar3); // expected-error{{cannot be defined in a parameter type}} |
| 29 | }; |
| 30 | |
| 31 | void pr19018_1 (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 32 | void pr19018_1a (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 33 | e19018_1 x2; // expected-error{{unknown type name 'e19018_1'}} |
| 34 | |
| 35 | void pr19018_2 (enum {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 36 | void pr19018_3 (struct s19018_2 {int qq;} x); // expected-error{{cannot be defined in a parameter type}} |
| 37 | void pr19018_4 (struct {int qq;} x); // expected-error{{cannot be defined in a parameter type}} |
| 38 | void pr19018_5 (struct { void qq(); } x); // expected-error{{cannot be defined in a parameter type}} |
| 39 | void pr19018_5 (struct s19018_2 { void qq(); } x); // expected-error{{cannot be defined in a parameter type}} |
| 40 | |
| 41 | struct pr19018a { |
| 42 | static int xx; |
| 43 | void func1(enum t19018 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 44 | void func2(enum t19018 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 45 | void func3(enum {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 46 | void func4(struct t19018 {int qq;} x); // expected-error{{cannot be defined in a parameter type}} |
| 47 | void func5(struct {int qq;} x); // expected-error{{cannot be defined in a parameter type}} |
| 48 | void func6(struct { void qq(); } x); // expected-error{{cannot be defined in a parameter type}} |
| 49 | void func7(struct t19018 { void qq(); } x); // expected-error{{cannot be defined in a parameter type}} |
| 50 | void func8(struct { int qq() { return xx; }; } x); // expected-error{{cannot be defined in a parameter type}} |
| 51 | void func9(struct t19018 { int qq() { return xx; }; } x); // expected-error{{cannot be defined in a parameter type}} |
| 52 | }; |
| 53 | |
| 54 | struct s19018b { |
| 55 | void func1 (enum en_2 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 56 | en_2 x1; // expected-error{{unknown type name 'en_2'}} |
| 57 | void func2 (enum en_3 {qq} x); // expected-error{{cannot be defined in a parameter type}} |
| 58 | enum en_3 x2; // expected-error{{ISO C++ forbids forward references to 'enum' types}} \ |
| 59 | // expected-error{{field has incomplete type 'enum en_3'}} \ |
| 60 | // expected-note{{forward declaration of 'en_3'}} |
| 61 | }; |
| 62 | |
| 63 | struct pr18963 { |
| 64 | short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}} |
| 65 | long foo5 (float foo6 = foo4); // expected-error{{use of undeclared identifier 'foo4'}} |
| 66 | }; |