[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / type-definition-in-specifier.cpp
blobf6ad6b7e3108f95beed4f8ce3ae871625ddfa8f5
1 // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec -verify %std_cxx98- %s
3 struct S0;
4 struct S1;
5 struct S2;
6 struct S3;
7 struct S4;
8 struct S5;
9 struct S6;
11 struct S0 { int x; };
13 void f0() {
14 typedef struct S1 { int x; } S1_typedef;
16 (void)((struct S2 { int x; }*)0); // expected-error{{cannot be defined}}
18 struct S3 { int x; } s3;
20 (void)static_cast<struct S4 { int x; } *>(0); // expected-error{{cannot be defined}}
23 struct S5 { int x; } f1() { return S5(); } // expected-error{{result type}}
25 void f2(struct S6 { int x; } p); // expected-error{{parameter type}}
27 struct pr19018 {
28 short foo6 (enum bar0 {qq} bar3); // expected-error{{cannot be defined in a parameter type}}
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;
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}}
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}}
54 struct s19018b {
55 void func1 (enum en_2 {qq} x); // expected-error{{cannot be defined in a parameter type}}
56 en_2 x1;
57 void func2 (enum en_3 {qq} x); // expected-error{{cannot be defined in a parameter type}}
58 enum en_3 x2;
61 struct pr18963 {
62 short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}}
63 long foo5 (float foo6 = foo4);
66 // expected-error@+2 {{cannot be defined in a parameter type}}
67 // expected-note@+1 {{previous definition is here}}
68 void func_with_eh_and_type(struct type_in_eh {} o) throw(int) {}
69 struct type_in_eh {}; // expected-error {{redefinition of 'type_in_eh'}}