OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [obj-c++.dg/] [encode-6.mm] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Encoding tests for ObjC class layouts.  */
2
/* Contributed by Ziemowit Laski .  */
3
/* { dg-options "-lobjc" } */
4
/* { dg-do run } */
5
 
6
#include 
7
#ifdef __NEXT_RUNTIME__
8
#include 
9
#define OBJC_GETCLASS objc_getClass
10
#else
11
#include 
12
#define OBJC_GETCLASS objc_get_class
13
#endif
14
 
15
#include 
16
#include 
17
 
18
#define CHECK_IF(expr) if(!(expr)) abort()
19
 
20
@class Int1, Int2;
21
struct Nested;
22
 
23
struct Innermost {
24
  unsigned char a, b;
25
  struct Nested *encl;
26
};
27
 
28
struct Nested {
29
  float a, b;
30
  Int1 *next;
31
  struct Innermost innermost;
32
};
33
 
34
@interface Int1: Object {
35
  signed char a, b;
36
  Int2 *int2;
37
  struct Nested nested;
38
}
39
@end
40
 
41
@interface Int2: Int1 {
42
  struct Innermost *innermost;
43
  Int1 *base;
44
}
45
@end
46
 
47
@implementation Int1
48
@end
49
 
50
@implementation Int2
51
@end
52
 
53
struct objc_ivar *ivar;
54
 
55
static void check_ivar(const char *name, const char *type) {
56
  CHECK_IF(!strcmp(ivar->ivar_name, name));
57
  CHECK_IF(!strcmp(ivar->ivar_type, type));
58
  ivar++;
59
}
60
 
61
int main(void) {
62
  ivar = ((Class)OBJC_GETCLASS("Int1"))->ivars->ivar_list;
63
  check_ivar("a", "c");
64
  check_ivar("b", "c");
65
  check_ivar("int2", "@\"Int2\"");
66
  check_ivar("nested",
67
    "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
68
 
69
  ivar = ((Class)OBJC_GETCLASS("Int2"))->ivars->ivar_list;
70
  check_ivar("innermost", "^{Innermost=CC^{Nested}}");
71
  check_ivar("base", "@\"Int1\"");
72
 
73
  return 0;
74
}

powered by: WebSVN 2.1.0

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