84 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3typedef signed char BOOL;4typedef unsigned int NSUInteger;5typedef struct _NSZone NSZone;6@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;7@protocol NSObject8- (BOOL)isEqual:(id)object;9@end10@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;11@end12@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;13@end14@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;15@end16@interface NSObject <NSObject> {}17@end18extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);19typedef struct {20 id *itemsPtr;21 unsigned long *mutationsPtr;22} NSFastEnumerationState;23@protocol NSFastEnumeration24- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;25@end26@class NSString;27@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;28@end29@interface NSMutableArray : NSArray - (void)addObject:(id)anObject;30@end31extern NSString * const NSUndoManagerCheckpointNotification;32@interface NSValueTransformer : NSObject {} @end33@class FooModel;34@interface FooObject : NSObject <NSCopying> {}35@end36@interface FooNode : FooObject {}37- (NSArray *) children;38@end39typedef enum { Foo_HUH_NONE } FooHUHCode;40@interface FooPlaypenEntry : FooNode {41 NSMutableArray *_interestingChildren;42 FooHUHCode _HUH;43 __attribute__((objc_gc(weak))) FooPlaypenEntry *_mostInterestingChild;44 id _author;45}46@property(copy) NSString *author;47- (BOOL) isInteresting;48@end NSString *FooHUHCodeToString(FooHUHCode HUH) { return 0; }49@interface FooHUHCodeToStringTransformer: NSValueTransformer {50}51@end @implementation FooPlaypenEntry @synthesize author = _author;52- (BOOL) isInteresting { return 1; }53- (NSArray *) interestingChildren {54 if (!_interestingChildren) {55 for (FooPlaypenEntry *child in [self children]) {56 if ([child isInteresting]) {57 if (!_mostInterestingChild)58 _mostInterestingChild = child;59 else if (child->_HUH > _mostInterestingChild->_HUH) 60 _mostInterestingChild = child;61 }62 }63 }64 return 0;65}66- (FooHUHCode) HUH {67 if (_HUH == Foo_HUH_NONE) {68 if (_mostInterestingChild)69 return [_mostInterestingChild HUH];70 }71 return 0;72}73@end74 75@interface Test1 {76@public77 id ivar __attribute__((objc_gc(weak)));78}79@property (assign) id prop __attribute((objc_gc(weak)));80@end81void test1(Test1 *t) {82 id *(__attribute__((objc_gc(strong))) x) = &t->ivar; // expected-warning {{initializing '__strong id *' with an expression of type '__weak id *' discards qualifiers}}83}84