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