summaryrefslogtreecommitdiffstats
path: root/test/SemaObjC/property-typecheck-1.m
blob: f86e047799917279bda7e3dea9d54079d085daf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// RUN: %clang_cc1 -fsyntax-only -verify %s

@interface A
-(float) x;	// expected-note {{declared here}}
@property int x; // expected-warning {{type of property 'x' does not match type of accessor 'x'}}
@end

@interface A (Cat)
@property int moo;	// expected-note {{previous definition is here}}
@end

@implementation A (Cat)
-(int) moo {
  return 0;
}
-(void) setMoo: (float) x { // expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}}
}
@end


typedef int T[2];
typedef void (F)(void);

@interface C
@property(assign) T p2;  // expected-error {{property cannot have array or function type 'T'}}

@property(assign) F f2; // expected-error {{property cannot have array or function type 'F'}}

@end


@class SSyncSet;

@interface SPeer
  @property(nonatomic,readonly,retain) SSyncSet* syncSet;
@end

@class SSyncSet_iDisk;

@interface SPeer_iDisk_remote1 : SPeer
- (SSyncSet_iDisk*) syncSet; // expected-note {{declared here}}
@end

@interface SPeer_iDisk_local
- (SSyncSet_iDisk*) syncSet;
@end

@interface SSyncSet
@end

@interface SSyncSet_iDisk
@property(nonatomic,readonly,retain) SPeer_iDisk_local* localPeer;
@end

@interface SPeer_iDisk_remote1 (protected)
@end

@implementation SPeer_iDisk_remote1 (protected)
- (id) preferredSource1
{
  return self.syncSet.localPeer; // expected-warning {{type of property 'syncSet' does not match type of accessor 'syncSet'}}
}
@end

@interface NSArray @end

@interface NSMutableArray : NSArray
@end

@interface Class1 
{
 NSMutableArray* pieces;
 NSArray* first;
}

@property (readonly) NSArray* pieces;  // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
@property (readonly) NSMutableArray* first; 

- (NSMutableArray*) pieces; // expected-note {{declared here}} // expected-note {{declared here}}
- (NSArray*) first;
@end

@interface Class2  {
 Class1* container;
}

@end

@implementation Class2

- (id) lastPiece
{
 return container.pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
}

- (id)firstPeice
{
  return container.first; 
}
@end

OpenPOWER on IntegriCloud