70 lines · cpp
1// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec -verify %std_cxx98- %s2 3struct S0;4struct S1;5struct S2;6struct S3;7struct S4;8struct S5;9struct S6;10 11struct S0 { int x; };12 13void f0() {14 typedef struct S1 { int x; } S1_typedef;15 16 (void)((struct S2 { int x; }*)0); // expected-error{{cannot be defined}}17 18 struct S3 { int x; } s3;19 20 (void)static_cast<struct S4 { int x; } *>(0); // expected-error{{cannot be defined}}21}22 23struct S5 { int x; } f1() { return S5(); } // expected-error{{result type}}24 25void f2(struct S6 { int x; } p); // expected-error{{parameter type}}26 27struct pr19018 {28 short foo6 (enum bar0 {qq} bar3); // expected-error{{cannot be defined in a parameter type}}29};30 31void pr19018_1 (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}32void pr19018_1a (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}33e19018_1 x2;34 35void pr19018_2 (enum {qq} x); // expected-error{{cannot be defined in a parameter type}}36void pr19018_3 (struct s19018_2 {int qq;} x); // expected-error{{cannot be defined in a parameter type}}37void pr19018_4 (struct {int qq;} x); // expected-error{{cannot be defined in a parameter type}}38void pr19018_5 (struct { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}39void pr19018_5 (struct s19018_2 { void qq(); } x); // expected-error{{cannot be defined in a parameter type}}40 41struct 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 54struct 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;59};60 61struct pr18963 {62 short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}}63 long foo5 (float foo6 = foo4);64};65 66// expected-error@+2 {{cannot be defined in a parameter type}}67// expected-note@+1 {{previous definition is here}}68void func_with_eh_and_type(struct type_in_eh {} o) throw(int) {}69struct type_in_eh {}; // expected-error {{redefinition of 'type_in_eh'}}70