| 1 |
/* Check if objc_super stack variables are created correctly (and |
| 2 |
not clobbered by other values). */ |
| 3 |
/* Contributed by Ziemowit Laski <[email protected]>. */ |
| 4 |
/* { dg-options "-std=c99" } */ |
| 5 |
/* { dg-do run } */ |
| 6 |
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ |
| 7 |
|
| 8 |
#include "../objc-obj-c++-shared/TestsuiteObject.m" |
| 9 |
|
| 10 |
extern void abort(void); |
| 11 |
|
| 12 |
#define CHECK_IF(expr) if(!(expr)) abort(); |
| 13 |
|
| 14 |
typedef struct _Point { |
| 15 |
float x; |
| 16 |
float y; |
| 17 |
} Point; |
| 18 |
|
| 19 |
Point MakePoint ( float x , float y ) { |
| 20 |
Point p; |
| 21 |
p.x = x; |
| 22 |
p.y = y; |
| 23 |
return p; |
| 24 |
} |
| 25 |
|
| 26 |
@interface Base: TestsuiteObject |
| 27 |
- ( void ) translateOriginToPoint : ( Point ) translation ; |
| 28 |
@end |
| 29 |
|
| 30 |
@interface Derived : Base |
| 31 |
- ( void ) scrollToPoint : ( Point ) newOrigin ; |
| 32 |
- ( void ) translateOriginToPoint : ( Point ) translation ; |
| 33 |
@end |
| 34 |
|
| 35 |
int blort; |
| 36 |
float result; |
| 37 |
|
| 38 |
@implementation Base |
| 39 |
- ( void ) translateOriginToPoint : ( Point ) translation { |
| 40 |
result = translation.x + translation.y; |
| 41 |
} |
| 42 |
@end |
| 43 |
|
| 44 |
@implementation Derived |
| 45 |
- ( void ) scrollToPoint : ( Point ) newOrigin { |
| 46 |
float transDeltaX =newOrigin.x, transDeltaY =newOrigin.y ; |
| 47 |
Point w; |
| 48 |
if ( ! blort ) { |
| 49 |
w.x = transDeltaX ; w.y = transDeltaY ; |
| 50 |
[ super translateOriginToPoint : w ] ; |
| 51 |
return; |
| 52 |
} |
| 53 |
[ super translateOriginToPoint : MakePoint ( transDeltaX , transDeltaY ) ] ; |
| 54 |
return; |
| 55 |
} |
| 56 |
- (void) translateOriginToPoint : ( Point ) translation { |
| 57 |
/* This should never be called. */ |
| 58 |
CHECK_IF(0); |
| 59 |
} |
| 60 |
@end |
| 61 |
|
| 62 |
int main(void) { |
| 63 |
Derived *v = [Derived new]; |
| 64 |
float r0 = 1.5 + 1.5; |
| 65 |
blort = 1; |
| 66 |
[v scrollToPoint: MakePoint(1.5, 1.5)]; |
| 67 |
CHECK_IF(result == r0); |
| 68 |
blort = 0; |
| 69 |
[v scrollToPoint: MakePoint(1.5, 1.5)]; |
| 70 |
CHECK_IF(result == r0); |
| 71 |
blort = 1; |
| 72 |
[v scrollToPoint: MakePoint(1.5, 1.5)]; |
| 73 |
CHECK_IF(result == r0); |
| 74 |
[v free]; |
| 75 |
return 0; |
| 76 |
} |
| 77 |
|
| 78 |
|