blob: a3220ebc64774caea97da587393657b03476408a [file] [log] [blame]
Anders Carlssone9b801f2011-02-22 01:52:06 +00001// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
2// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -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) {
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000030 @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} \
31 // expected-warning {{expression result unused}}
Chris Lattnera868a202009-04-21 06:11:25 +000032 }
33 @catch (float x) { // expected-error {{@catch parameter is not a pointer to an interface type}}
34
Chris Lattnercb53b362007-12-27 19:57:00 +000035 }
36 @catch(...) {
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000037 @throw (4,3,proc()); // expected-warning {{expression result unused}} \
38 // expected-warning {{expression result unused}}
Chris Lattnercb53b362007-12-27 19:57:00 +000039 }
40 }
Fariborz Jahanian397fcc12007-09-19 19:14:32 +000041
Gabor Greif1b767792008-05-23 11:19:39 +000042 @try { // expected-error {{@try statement without a @catch and @finally clause}}
Chris Lattnercb53b362007-12-27 19:57:00 +000043 return proc();
44 }
45}
46
47
48void bar()
49{
Gabor Greif1b767792008-05-23 11:19:39 +000050 @try {}// expected-error {{@try statement without a @catch and @finally clause}}
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000051 @"s"; // expected-warning {{result unused}}
Chris Lattnercb53b362007-12-27 19:57:00 +000052}
53
54void baz()
55{
Gabor Greif1b767792008-05-23 11:19:39 +000056 @try {}// expected-error {{@try statement without a @catch and @finally clause}}
Chris Lattner6b884502008-03-10 06:06:04 +000057 @try {}
Chris Lattnercb53b362007-12-27 19:57:00 +000058 @finally {}
Fariborz Jahanian397fcc12007-09-19 19:14:32 +000059}
60
Steve Naroff64515f32008-02-05 21:27:35 +000061void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() {
62 @try {
63 // Do something
64 } @catch (...) {}
65 @try {
66 // Do something
67 } @catch (...) {}
Chris Lattner65ce04b2008-12-18 02:01:17 +000068 return;
Steve Naroff64515f32008-02-05 21:27:35 +000069}
70