diff options
Diffstat (limited to 'clang/test/SemaCXX/exceptions.cpp')
| -rw-r--r-- | clang/test/SemaCXX/exceptions.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp new file mode 100644 index 00000000000..508f23d148e --- /dev/null +++ b/clang/test/SemaCXX/exceptions.cpp @@ -0,0 +1,67 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +struct A; // expected-note 4 {{forward declaration of 'struct A'}} + +void trys() { + try { + } catch(int i) { // expected-note {{previous definition}} + int j = i; + int i; // expected-error {{redefinition of 'i'}} + } catch(float i) { + } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}} + } catch(A a) { // expected-error {{cannot catch incomplete type 'struct A'}} + } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'struct A'}} + } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'struct A'}} + } catch(...) { + int j = i; // expected-error {{use of undeclared identifier 'i'}} + } + + try { + } catch(...) { // expected-error {{catch-all handler must come last}} + } catch(int) { + } +} + +void throws() { + throw; + throw 0; + throw throw; // expected-error {{cannot throw object of incomplete type 'void'}} + throw (A*)0; // expected-error {{cannot throw pointer to object of incomplete type 'struct A'}} +} + +void jumps() { +l1: + goto l5; + goto l4; // expected-error {{illegal goto into protected scope}} + goto l3; // expected-error {{illegal goto into protected scope}} + goto l2; // expected-error {{illegal goto into protected scope}} + goto l1; + try { // expected-note 4 {{jump bypasses initialization of try block}} + l2: + goto l5; + goto l4; // expected-error {{illegal goto into protected scope}} + goto l3; // expected-error {{illegal goto into protected scope}} + goto l2; + goto l1; + } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}} + l3: + goto l5; + goto l4; // expected-error {{illegal goto into protected scope}} + goto l3; + goto l2; // expected-error {{illegal goto into protected scope}} + goto l1; + } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}} + l4: + goto l5; + goto l4; + goto l3; // expected-error {{illegal goto into protected scope}} + goto l2; // expected-error {{illegal goto into protected scope}} + goto l1; + } +l5: + goto l5; + goto l4; // expected-error {{illegal goto into protected scope}} + goto l3; // expected-error {{illegal goto into protected scope}} + goto l2; // expected-error {{illegal goto into protected scope}} + goto l1; +} |

