| 1 |
/* Contributed by Nicola Pero <[email protected]>, November 2010. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
/* Test dot-syntax with accessors to be looked up in protocol @properties. */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
#include <objc/objc.h> |
| 8 |
#include <objc/runtime.h> |
| 9 |
|
| 10 |
@protocol ProtocolA |
| 11 |
@property int countA; |
| 12 |
@end |
| 13 |
|
| 14 |
@protocol ProtocolB |
| 15 |
@property int countB; |
| 16 |
@end |
| 17 |
|
| 18 |
@protocol ProtocolC |
| 19 |
@property int countC; |
| 20 |
@end |
| 21 |
|
| 22 |
@interface MyRootClass |
| 23 |
{ |
| 24 |
Class isa; |
| 25 |
} |
| 26 |
+ (id) initialize; |
| 27 |
+ (id) alloc; |
| 28 |
- (id) init; |
| 29 |
@end |
| 30 |
|
| 31 |
@interface MySubClass <ProtocolA, ProtocolB, ProtocolC> |
| 32 |
@end |
| 33 |
|
| 34 |
int function (MySubClass *object, int x) |
| 35 |
{ |
| 36 |
object.countA = x; |
| 37 |
object.countB = x; |
| 38 |
object.countC = object.countB; |
| 39 |
|
| 40 |
return object.countC; |
| 41 |
} |
| 42 |
|
| 43 |
int function2 (MyRootClass <ProtocolA, ProtocolB, ProtocolC> *object, int x) |
| 44 |
{ |
| 45 |
object.countA = x; |
| 46 |
object.countB = x; |
| 47 |
object.countC = object.countB; |
| 48 |
|
| 49 |
return object.countC; |
| 50 |
} |
| 51 |
|
| 52 |
int function3 (MyRootClass <ProtocolA, ProtocolB> *object, int x) |
| 53 |
{ |
| 54 |
object.countA = x; |
| 55 |
object.countB = x; |
| 56 |
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */ |
| 57 |
|
| 58 |
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */ |
| 59 |
} |
| 60 |
|
| 61 |
int function4 (id <ProtocolA, ProtocolB, ProtocolC> object, int x) |
| 62 |
{ |
| 63 |
object.countA = x; |
| 64 |
object.countB = x; |
| 65 |
object.countC = object.countB; |
| 66 |
|
| 67 |
return object.countC; |
| 68 |
} |
| 69 |
|
| 70 |
int function5 (id <ProtocolA, ProtocolB> object, int x) |
| 71 |
{ |
| 72 |
object.countA = x; |
| 73 |
object.countB = x; |
| 74 |
object.countC = object.countB; /* { dg-error "request for member .countC. in something not a structure or union" } */ |
| 75 |
|
| 76 |
return object.countC; /* { dg-error "request for member .countC. in something not a structure or union" } */ |
| 77 |
} |