blob: 98c6d16ff6987d2f4c4ce9157c2ac015d5b4df46 [file] [log] [blame]
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00001// RUN: clang-cc -fsyntax-only -verify %s
Daniel Dunbard7d5f022009-03-24 02:24:46 +00002// RUN: clang-cc -fsyntax-only -verify -x objective-c++ %s
Fariborz Jahanian397fcc12007-09-19 19:14:32 +00003void * proc();
4
Chris Lattner6b884502008-03-10 06:06:04 +00005@interface NSConstantString
6@end
7
Fariborz Jahanian397fcc12007-09-19 19:14:32 +00008@interface Frob
9@end
10
11@interface Frob1
12@end
13
14void * foo()
15{
Chris Lattnercb53b362007-12-27 19:57:00 +000016 @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 Lattnera868a202009-04-21 06:11:25 +000030 @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 Lattnercb53b362007-12-27 19:57:00 +000034 }
35 @catch(...) {
36 @throw (4,3,proc());
37 }
38 }
Fariborz Jahanian397fcc12007-09-19 19:14:32 +000039
Gabor Greif1b767792008-05-23 11:19:39 +000040 @try { // expected-error {{@try statement without a @catch and @finally clause}}
Chris Lattnercb53b362007-12-27 19:57:00 +000041 return proc();
42 }
43}
44
45
46void bar()
47{
Gabor Greif1b767792008-05-23 11:19:39 +000048 @try {}// expected-error {{@try statement without a @catch and @finally clause}}
Chris Lattner6b884502008-03-10 06:06:04 +000049 @"s"; // expected-warning {{result unused}}
Chris Lattnercb53b362007-12-27 19:57:00 +000050}
51
52void baz()
53{
Gabor Greif1b767792008-05-23 11:19:39 +000054 @try {}// expected-error {{@try statement without a @catch and @finally clause}}
Chris Lattner6b884502008-03-10 06:06:04 +000055 @try {}
Chris Lattnercb53b362007-12-27 19:57:00 +000056 @finally {}
Fariborz Jahanian397fcc12007-09-19 19:14:32 +000057}
58
Steve Naroff64515f32008-02-05 21:27:35 +000059void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() {
60 @try {
61 // Do something
62 } @catch (...) {}
63 @try {
64 // Do something
65 } @catch (...) {}
Chris Lattner65ce04b2008-12-18 02:01:17 +000066 return;
Steve Naroff64515f32008-02-05 21:27:35 +000067}
68