1// RUN: %clang_cc1 -emit-llvm -o %t %s 2 3int printf(const char *, ...); 4 5@interface Root 6-(id) alloc; 7-(id) init; 8@end 9 10// Property above methods... 11 12@interface Top0 : Root 13@property(getter=_getX,setter=_setX:) int x; 14@end 15 16@interface Bot0 : Top0 17-(int) x; 18-(void) setX: (int) arg; 19@end 20 21@implementation Top0 22-(int) _getX { 23 printf("-[ Top0 _getX ]\n"); 24 return 0; 25} 26-(void) _setX: (int) arg { 27 printf("-[ Top0 _setX: %d ]\n", arg); 28} 29@end 30 31@implementation Bot0 32-(int) x { 33 printf("-[ Bot0 _getX ]\n"); 34 return 0; 35} 36-(void) setX: (int) arg { 37 printf("-[ Bot0 _setX: %d ]\n", arg); 38} 39@end 40 41// Methods above property... 42 43@interface Top1 : Root 44-(int) x; 45-(void) setX: (int) arg; 46@end 47 48@interface Bot1 : Top1 49@property(getter=_getX,setter=_setX:) int x; 50@end 51 52@implementation Top1 53-(int) x { 54 printf("-[ Top1 x ]\n"); 55 return 0; 56} 57-(void) setX: (int) arg { 58 printf("-[ Top1 setX: %d ]\n", arg); 59} 60@end 61 62@implementation Bot1 63-(int) _getX { 64 printf("-[ Bot1 _getX ]\n"); 65 return 0; 66} 67-(void) _setX: (int) arg { 68 printf("-[ Bot1 _setX: %d ]\n", arg); 69} 70@end 71 72// Mixed setter & getter (variant 1) 73 74@interface Top2 : Root 75-(int) x; 76-(void) _setX: (int) arg; 77@end 78 79@interface Bot2 : Top2 80@property(getter=_getX,setter=_setX:) int x; 81@end 82 83@implementation Top2 84-(int) x { 85 printf("-[ Top2 x ]\n"); 86 return 0; 87} 88-(void) _setX: (int) arg { 89 printf("-[ Top2 _setX: %d ]\n", arg); 90} 91@end 92 93@implementation Bot2 94-(int) _getX { 95 printf("-[ Bot2 _getX ]\n"); 96 return 0; 97} 98-(void) setX: (int) arg { 99 printf("-[ Bot2 setX: %d ]\n", arg); 100} 101@end 102 103// Mixed setter & getter (variant 2) 104 105@interface Top3 : Root 106-(int) _getX; 107-(void) setX: (int) arg; 108@end 109 110@interface Bot3 : Top3 111@property(getter=_getX,setter=_setX:) int x; 112@end 113 114@implementation Top3 115-(int) _getX { 116 printf("-[ Top3 _getX ]\n"); 117 return 0; 118} 119-(void) setX: (int) arg { 120 printf("-[ Top3 setX: %d ]\n", arg); 121} 122@end 123 124@implementation Bot3 125-(int) x { 126 printf("-[ Bot3 x ]\n"); 127 return 0; 128} 129-(void) _setX: (int) arg { 130 printf("-[ Bot3 _setX: %d ]\n", arg); 131} 132@end 133 134// Mixed setter & getter (variant 3) 135 136@interface Top4 : Root 137@property(getter=_getX,setter=_setX:) int x; 138@end 139 140@interface Bot4 : Top4 141-(int) _getX; 142-(void) setX: (int) arg; 143@end 144 145@implementation Top4 146-(int) x { 147 printf("-[ Top4 x ]\n"); 148 return 0; 149} 150-(void) _setX: (int) arg { 151 printf("-[ Top4 _setX: %d ]\n", arg); 152} 153@end 154 155@implementation Bot4 156-(int) _getX { 157 printf("-[ Bot4 _getX ]\n"); 158 return 0; 159} 160-(void) setX: (int) arg { 161 printf("-[ Bot4 setX: %d ]\n", arg); 162} 163@end 164 165// Mixed setter & getter (variant 4) 166 167@interface Top5 : Root 168@property(getter=_getX,setter=_setX:) int x; 169@end 170 171@interface Bot5 : Top5 172-(int) x; 173-(void) _setX: (int) arg; 174@end 175 176@implementation Top5 177-(int) _getX { 178 printf("-[ Top5 _getX ]\n"); 179 return 0; 180} 181-(void) setX: (int) arg { 182 printf("-[ Top5 setX: %d ]\n", arg); 183} 184@end 185 186@implementation Bot5 187-(int) x { 188 printf("-[ Bot5 x ]\n"); 189 return 0; 190} 191-(void) _setX: (int) arg { 192 printf("-[ Bot5 _setX: %d ]\n", arg); 193} 194@end 195 196// Mixed level calls (variant 1) 197 198@interface Top6 : Root 199-(int) x; 200@end 201 202@interface Bot6 : Top6 203-(void) setX: (int) arg; 204@end 205 206@implementation Top6 207-(int) x { 208 printf("-[ Top6 x ]\n"); 209 return 0; 210} 211@end 212 213@implementation Bot6 214-(void) setX: (int) arg { 215 printf("-[ Bot5 setX: %d ]\n", arg); 216} 217@end 218 219// Mixed level calls (variant 1) 220 221@interface Top7 : Root 222-(void) setX: (int) arg; 223@end 224 225@interface Bot7 : Top7 226-(int) x; 227@end 228 229@implementation Top7 230-(void) setX: (int) arg { 231 printf("-[ Top7 setX: %d ]\n", arg); 232} 233@end 234 235@implementation Bot7 236-(int) x { 237 printf("-[ Bot7 x ]\n"); 238 return 0; 239} 240@end 241 242// 243 244// FIXME: Two more (thats it?) interesting cases. Method access on 245// getter w/o setter and method access on setter w/o getter. 246 247int main() { 248#define test(N) { \ 249 Bot##N *ob = [[Bot##N alloc] init]; \ 250 int x = ob.x; \ 251 ob.x = 10; } 252 253 test(0); 254 test(1); 255 test(2); 256 test(3); 257 test(4); 258 test(5); 259 // test(6); 260 // test(7); 261 262 return 0; 263} 264 265