1 /* Check if the @defs() construct preserves the correct
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-options "" } */
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
8 #include "../objc-obj-c++-shared/TestsuiteObject.m"
9 //#include <objc/objc.h>
11 extern void abort(void);
13 #define CHECK_IF(expr) if(!(expr)) abort();
15 @interface Base: TestsuiteObject {
23 @interface Derived: Base {
38 @implementation Derived
52 Derived *derived = [[Derived alloc] init];
53 struct Derived_defs *derived_defs = (struct Derived_defs *)derived;
55 CHECK_IF(derived->a == derived_defs->a && derived_defs->a == 123);
56 CHECK_IF(derived->b == derived_defs->b && derived_defs->b == (float)1.23);
57 CHECK_IF(derived->c == derived_defs->c && derived_defs->c == 'c');
58 CHECK_IF(derived->d == derived_defs->d && derived_defs->d == (double)123.456);
59 CHECK_IF(derived->e == derived_defs->e && derived_defs->e == 456);
60 CHECK_IF(derived->f == derived_defs->f && derived_defs->f == derived_defs->isa);
62 /* Try out the "inline" notation as well. */
63 CHECK_IF(((struct { @defs(Derived); } *)derived)->a == 123);
64 CHECK_IF(((struct { @defs(Derived); } *)derived)->c == 'c');
65 CHECK_IF(((struct { @defs(Derived); } *)derived)->e == 456);