53 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Werror=return-type %s2typedef signed char BOOL;3typedef struct _NSZone NSZone;4 5@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;6 7@protocol NSObject8- (BOOL)isEqual:(id)object;9@end10 11@protocol NSCopying12- (id)copyWithZone:(NSZone *)zone;13@end14 15@protocol NSCoding16- (void)encodeWithCoder:(NSCoder *)aCoder;17@end18 19@interface NSObject <NSObject> {}20@end21 22@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;23 24@interface NSException : NSObject <NSCopying, NSCoding> {}25@end26 27@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo;28 29@interface XCRefactoringTransformation : NSObject {}30@end31 32@implementation XCRefactoringTransformation33- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError {34 @try {}35 // the exception name is optional (weird)36 @catch (NSException *) {}37} // expected-error {{non-void function does not return a value}}38 39- (NSDictionary *)anotherFunction {40 @try {}41 @finally {}42} // FIXME: This should warn about a missing return too.43@end44 45int foo(void) {46 struct s { int a, b; } agg, *pagg;47 48 @throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}49 @throw agg; // expected-error {{@throw requires an Objective-C object type ('struct s' invalid)}}50 @throw pagg; // expected-error {{@throw requires an Objective-C object type ('struct s *' invalid)}}51 @throw; // expected-error {{@throw (rethrow) used outside of a @catch block}}52}53