OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [defs.m] - Blame information for rev 704

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* 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" } { "" } } */
7
 
8
#include "../objc-obj-c++-shared/TestsuiteObject.m"
9
//#include <objc/objc.h>
10
 
11
extern void abort(void);
12
 
13
#define CHECK_IF(expr) if(!(expr)) abort();
14
 
15
@interface Base: TestsuiteObject {
16
@public
17
  int a;
18
  float b;
19
  char c;
20
}
21
@end
22
 
23
@interface Derived: Base {
24
@public
25
  double d;
26
  unsigned e;
27
  id f;
28
}
29
- init;
30
@end
31
 
32
struct Derived_defs {
33
  @defs(Derived);
34
};
35
 
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;
48
}
49
@end
50
 
51
int main(void) {
52
  Derived *derived = [[Derived alloc] init];
53
  struct Derived_defs *derived_defs = (struct Derived_defs *)derived;
54
 
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);
61
 
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);
66
 
67
  return 0;
68
}
69
 
70
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.