blob: e3d96da13bb792a8a878186baae04c17f29d8b56 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanianfb41ca82009-02-26 23:05:51 +00002
3typedef signed char BOOL;
4typedef unsigned int NSUInteger;
5typedef struct _NSZone NSZone;
6@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
7@protocol NSObject
8- (BOOL)isEqual:(id)object;
9@end
10@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
11@end
12@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
13@end
14@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
15@end
16@interface NSObject <NSObject> {}
17@end
18extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
19typedef struct {
20 id *itemsPtr;
21 unsigned long *mutationsPtr;
22} NSFastEnumerationState;
23@protocol NSFastEnumeration
24- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
25@end
26@class NSString;
27@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
28@end
29@interface NSMutableArray : NSArray - (void)addObject:(id)anObject;
30@end
31extern NSString * const NSUndoManagerCheckpointNotification;
32@interface NSValueTransformer : NSObject {} @end
33@class FooModel;
34@interface FooObject : NSObject <NSCopying> {}
35@end
36@interface FooNode : FooObject {}
37- (NSArray *) children;
38@end
39typedef 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;
Mike Stumpd1969d82009-07-22 00:43:08 +000048@end NSString *FooHUHCodeToString(FooHUHCode HUH) { return 0; }
Fariborz Jahanianfb41ca82009-02-26 23:05:51 +000049@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 }
Mike Stumpd1969d82009-07-22 00:43:08 +000064 return 0;
Fariborz Jahanianfb41ca82009-02-26 23:05:51 +000065}
66- (FooHUHCode) HUH {
67 if (_HUH == Foo_HUH_NONE) {
68 if (_mostInterestingChild)
69 return [_mostInterestingChild HUH];
70 }
Mike Stumpd1969d82009-07-22 00:43:08 +000071 return 0;
Fariborz Jahanianfb41ca82009-02-26 23:05:51 +000072}
73@end
74
John McCall7ea21932011-03-26 01:39:56 +000075// rdar://problem/9123040
76@interface Test1 {
77@public
78 id ivar __attribute__((objc_gc(weak)));
79}
80@property (assign) id prop __attribute((objc_gc(weak)));
81@end
82void test1(Test1 *t) {
83 id *(__attribute__((objc_gc(strong))) x) = &t->ivar; // expected-warning {{initializing '__strong id *' with an expression of type '__weak id *' discards qualifiers}}
84}