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