[ARM] PR target/67929 Tighten vfp3_const_double_for_bits checks
[official-gcc.git] / gcc / testsuite / objc.dg / defs.m
blob5ea1f34b6d29c40565db50cab9fafd80b1119b05
1 /* Check if the @defs() construct preserves the correct
2    offsets of ivars.  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-options "" } */
5 /* { dg-do run } */
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 {
16 @public
17   int a;
18   float b;
19   char c;
21 @end
23 @interface Derived: Base {
24 @public
25   double d;
26   unsigned e;
27   id f;
28
29 - init;
30 @end
32 struct Derived_defs {
33   @defs(Derived);
36 @implementation Base
37 @end
38 @implementation Derived
39 - init {
40   [super init];
41   a = 123;
42   b = 1.23;
43   c = 'c';
44   d = 123.456;
45   e = 456;
46   f = isa;
47   return self;
49 @end
51 int main(void) {
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);
67   return 0;