1 /* Test for handling of struct-returning methods. */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.m"
8 extern void abort(void);
9 #define CHECK_IF(expr) if(!(expr)) abort()
13 } globa = { 1.0, 2.0 };
16 float a, b, c, d, e, f;
17 } globb = { 1, 2, 3, 4, 5, 6 };
19 @interface foo : TestsuiteObject
20 - (struct astruct) stret;
21 - (struct bstruct) stretb;
24 @implementation foo : TestsuiteObject
25 - (struct astruct) stret { return globa; }
26 - (struct bstruct) stretb { return globb; }
30 - (struct astruct) stret;
31 - (struct bstruct) stretb;
35 - (struct astruct) stret { struct astruct a = [super stret]; a.b = 77; return a; }
36 - (struct bstruct) stretb { struct bstruct b = [super stretb]; b.e = 99; return b; }
42 bar *obj2 = [bar new];
43 struct astruct loc, loc2;
44 struct bstruct locb, locb2;
47 CHECK_IF(loc.a == 1.0 && loc.b == 2.0);
50 CHECK_IF(locb.f == 6 && locb.c == 3);
51 CHECK_IF(locb.e == 5 && locb.b == 2);
52 CHECK_IF(locb.d == 4 && locb.a == 1);
55 CHECK_IF(loc2.a == 1.0 && loc2.b == 77);
57 locb2 = [obj2 stretb];
58 CHECK_IF(locb2.f == 6 && locb2.c == 3);
59 CHECK_IF(locb2.e == 99 && locb2.b == 2);
60 CHECK_IF(locb2.d == 4 && locb2.a == 1);