Anders Carlsson | e9b801f | 2011-02-22 01:52:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -x objective-c++ %s |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 3 | void * proc(); |
| 4 | |
Chris Lattner | 6b88450 | 2008-03-10 06:06:04 +0000 | [diff] [blame] | 5 | @interface NSConstantString |
| 6 | @end |
| 7 | |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 8 | @interface Frob |
| 9 | @end |
| 10 | |
| 11 | @interface Frob1 |
| 12 | @end |
| 13 | |
| 14 | void * foo() |
| 15 | { |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 16 | @try { |
| 17 | return proc(); |
| 18 | } |
| 19 | @catch (Frob* ex) { |
| 20 | @throw; |
| 21 | } |
| 22 | @catch (Frob1* ex) { |
| 23 | @throw proc(); |
| 24 | } |
| 25 | @finally { |
| 26 | @try { |
| 27 | return proc(); |
| 28 | } |
| 29 | @catch (Frob* ex) { |
Argyrios Kyrtzidis | 1b2ad2f | 2010-09-19 23:03:35 +0000 | [diff] [blame] | 30 | @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} \ |
| 31 | // expected-warning {{expression result unused}} |
Chris Lattner | a868a20 | 2009-04-21 06:11:25 +0000 | [diff] [blame] | 32 | } |
| 33 | @catch (float x) { // expected-error {{@catch parameter is not a pointer to an interface type}} |
| 34 | |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 35 | } |
| 36 | @catch(...) { |
Argyrios Kyrtzidis | 1b2ad2f | 2010-09-19 23:03:35 +0000 | [diff] [blame] | 37 | @throw (4,3,proc()); // expected-warning {{expression result unused}} \ |
| 38 | // expected-warning {{expression result unused}} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 39 | } |
| 40 | } |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 41 | |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 42 | @try { // expected-error {{@try statement without a @catch and @finally clause}} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 43 | return proc(); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void bar() |
| 49 | { |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 50 | @try {}// expected-error {{@try statement without a @catch and @finally clause}} |
Argyrios Kyrtzidis | 1b2ad2f | 2010-09-19 23:03:35 +0000 | [diff] [blame] | 51 | @"s"; // expected-warning {{result unused}} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void baz() |
| 55 | { |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 56 | @try {}// expected-error {{@try statement without a @catch and @finally clause}} |
Chris Lattner | 6b88450 | 2008-03-10 06:06:04 +0000 | [diff] [blame] | 57 | @try {} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 58 | @finally {} |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Steve Naroff | 64515f3 | 2008-02-05 21:27:35 +0000 | [diff] [blame] | 61 | void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() { |
| 62 | @try { |
| 63 | // Do something |
| 64 | } @catch (...) {} |
| 65 | @try { |
| 66 | // Do something |
| 67 | } @catch (...) {} |
Chris Lattner | 65ce04b | 2008-12-18 02:01:17 +0000 | [diff] [blame] | 68 | return; |
Steve Naroff | 64515f3 | 2008-02-05 21:27:35 +0000 | [diff] [blame] | 69 | } |
| 70 | |