xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/try-catch.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
2*f4a2713aSLionel Sambuctypedef signed char BOOL;
3*f4a2713aSLionel Sambuctypedef struct _NSZone NSZone;
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc@protocol NSObject
8*f4a2713aSLionel Sambuc- (BOOL)isEqual:(id)object;
9*f4a2713aSLionel Sambuc@end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc@protocol NSCopying
12*f4a2713aSLionel Sambuc- (id)copyWithZone:(NSZone *)zone;
13*f4a2713aSLionel Sambuc@end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambuc@protocol NSCoding
16*f4a2713aSLionel Sambuc- (void)encodeWithCoder:(NSCoder *)aCoder;
17*f4a2713aSLionel Sambuc@end
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc@interface NSObject <NSObject> {}
20*f4a2713aSLionel Sambuc@end
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambuc@interface NSException : NSObject <NSCopying, NSCoding> {}
25*f4a2713aSLionel Sambuc@end
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo;
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc@interface XCRefactoringTransformation : NSObject {}
30*f4a2713aSLionel Sambuc@end
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc@implementation XCRefactoringTransformation
33*f4a2713aSLionel Sambuc- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError {
34*f4a2713aSLionel Sambuc    @try {}
35*f4a2713aSLionel Sambuc    // the exception name is optional (weird)
36*f4a2713aSLionel Sambuc    @catch (NSException *) {}
37*f4a2713aSLionel Sambuc}
38*f4a2713aSLionel Sambuc@end
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambucint foo() {
41*f4a2713aSLionel Sambuc  struct s { int a, b; } agg, *pagg;
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc  @throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
44*f4a2713aSLionel Sambuc  @throw agg; // expected-error {{@throw requires an Objective-C object type ('struct s' invalid)}}
45*f4a2713aSLionel Sambuc  @throw pagg; // expected-error {{@throw requires an Objective-C object type ('struct s *' invalid)}}
46*f4a2713aSLionel Sambuc  @throw; // expected-error {{@throw (rethrow) used outside of a @catch block}}
47*f4a2713aSLionel Sambuc}
48