blob: 42973eba70ed794cec460950d5b3d77075ddbdb3 [file] [log] [blame]
Sebastian Redl4de47b42009-04-27 20:27:31 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3struct A; // expected-note 4 {{forward declaration of 'struct A'}}
4
Sebastian Redl2f38ba52009-04-27 21:03:30 +00005struct Abstract { virtual void f() = 0; }; // expected-note {{pure virtual function 'f'}}
6
Sebastian Redl4de47b42009-04-27 20:27:31 +00007void trys() {
8 try {
9 } catch(int i) { // expected-note {{previous definition}}
10 int j = i;
11 int i; // expected-error {{redefinition of 'i'}}
12 } catch(float i) {
13 } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
14 } catch(A a) { // expected-error {{cannot catch incomplete type 'struct A'}}
15 } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'struct A'}}
16 } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'struct A'}}
Sebastian Redl2f38ba52009-04-27 21:03:30 +000017 } catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}}
Sebastian Redl4de47b42009-04-27 20:27:31 +000018 } catch(...) {
19 int j = i; // expected-error {{use of undeclared identifier 'i'}}
20 }
21
22 try {
23 } catch(...) { // expected-error {{catch-all handler must come last}}
24 } catch(int) {
25 }
26}
27
28void throws() {
29 throw;
30 throw 0;
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 'struct A'}}
33}
34
35void jumps() {
36l1:
37 goto l5;
38 goto l4; // expected-error {{illegal goto into protected scope}}
39 goto l3; // expected-error {{illegal goto into protected scope}}
40 goto l2; // expected-error {{illegal goto into protected scope}}
41 goto l1;
42 try { // expected-note 4 {{jump bypasses initialization of try block}}
43 l2:
44 goto l5;
45 goto l4; // expected-error {{illegal goto into protected scope}}
46 goto l3; // expected-error {{illegal goto into protected scope}}
47 goto l2;
48 goto l1;
49 } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
50 l3:
51 goto l5;
52 goto l4; // expected-error {{illegal goto into protected scope}}
53 goto l3;
54 goto l2; // expected-error {{illegal goto into protected scope}}
55 goto l1;
56 } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
57 l4:
58 goto l5;
59 goto l4;
60 goto l3; // expected-error {{illegal goto into protected scope}}
61 goto l2; // expected-error {{illegal goto into protected scope}}
62 goto l1;
63 }
64l5:
65 goto l5;
66 goto l4; // expected-error {{illegal goto into protected scope}}
67 goto l3; // expected-error {{illegal goto into protected scope}}
68 goto l2; // expected-error {{illegal goto into protected scope}}
69 goto l1;
70}