Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 2 | // RUN: clang-cc -fsyntax-only -verify -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) { |
Chris Lattner | a868a20 | 2009-04-21 06:11:25 +0000 | [diff] [blame] | 30 | @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} |
| 31 | } |
| 32 | @catch (float x) { // expected-error {{@catch parameter is not a pointer to an interface type}} |
| 33 | |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 34 | } |
| 35 | @catch(...) { |
| 36 | @throw (4,3,proc()); |
| 37 | } |
| 38 | } |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 39 | |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 40 | @try { // expected-error {{@try statement without a @catch and @finally clause}} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 41 | return proc(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | |
| 46 | void bar() |
| 47 | { |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 48 | @try {}// expected-error {{@try statement without a @catch and @finally clause}} |
Chris Lattner | 6b88450 | 2008-03-10 06:06:04 +0000 | [diff] [blame] | 49 | @"s"; // expected-warning {{result unused}} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | void baz() |
| 53 | { |
Gabor Greif | 1b76779 | 2008-05-23 11:19:39 +0000 | [diff] [blame] | 54 | @try {}// expected-error {{@try statement without a @catch and @finally clause}} |
Chris Lattner | 6b88450 | 2008-03-10 06:06:04 +0000 | [diff] [blame] | 55 | @try {} |
Chris Lattner | cb53b36 | 2007-12-27 19:57:00 +0000 | [diff] [blame] | 56 | @finally {} |
Fariborz Jahanian | 397fcc1 | 2007-09-19 19:14:32 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Steve Naroff | 64515f3 | 2008-02-05 21:27:35 +0000 | [diff] [blame] | 59 | void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() { |
| 60 | @try { |
| 61 | // Do something |
| 62 | } @catch (...) {} |
| 63 | @try { |
| 64 | // Do something |
| 65 | } @catch (...) {} |
Chris Lattner | 65ce04b | 2008-12-18 02:01:17 +0000 | [diff] [blame] | 66 | return; |
Steve Naroff | 64515f3 | 2008-02-05 21:27:35 +0000 | [diff] [blame] | 67 | } |
| 68 | |