1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
3 struct A; // expected-note 4 {{forward declaration of 'A'}}
5 struct Abstract { virtual void f() = 0; }; // expected-note {{unimplemented pure virtual method 'f'}}
9 } catch(int i) { // expected-note {{previous definition}}
11 int i; // expected-error {{redefinition of 'i'}}
13 } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
14 } catch(A a) { // expected-error {{cannot catch incomplete type 'A'}}
15 } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'A'}}
16 } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'A'}}
17 } catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}}
19 int j = i; // expected-error {{use of undeclared identifier 'i'}}
23 } catch(...) { // expected-error {{catch-all handler must come last}}
31 throw throw; // expected-error {{cannot throw object of incomplete type 'void'}}
32 throw (A*)0; // expected-error {{cannot throw pointer to object of incomplete type 'A'}}
38 goto l4; // expected-error {{cannot jump}}
39 goto l3; // expected-error {{cannot jump}}
40 goto l2; // expected-error {{cannot jump}}
42 try { // expected-note 4 {{jump bypasses initialization of try block}}
45 goto l4; // expected-error {{cannot jump}}
46 goto l3; // expected-error {{cannot jump}}
49 } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
52 goto l4; // expected-error {{cannot jump}}
54 goto l2; // expected-error {{cannot jump}}
56 } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
60 goto l3; // expected-error {{cannot jump}}
61 goto l2; // expected-error {{cannot jump}}
66 goto l4; // expected-error {{cannot jump}}
67 goto l3; // expected-error {{cannot jump}}
68 goto l2; // expected-error {{cannot jump}}
80 return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
87 BadReturn::BadReturn(int) try {
92 return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
96 return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
101 // Cannot throw an abstract type.
106 throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}}
108 virtual void test () = 0; // expected-note{{unimplemented pure virtual method 'test'}}
112 namespace NA { struct S; }
113 namespace NB { struct S; }
126 void f() throw (A[10]);
129 template<typename T> struct B {
130 void f() throw (B[10]);
132 template struct B<int>;
134 void f() throw (int[10], int(*)());
135 void f() throw (int*, int());
137 template<typename T> struct C {
138 void f() throw (T); // expected-error {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}}
143 struct E; // expected-note {{forward declaration}}
144 C<E[10]> e; // expected-note {{in instantiation of}}
147 void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}}