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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [encode-6.mm] - Blame information for rev 713

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Encoding tests for ObjC class layouts.  */
2
/* Contributed by Ziemowit Laski .  */
3
/* { dg-options "" } */
4
/* { dg-do run } */
5
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6
#include "../objc-obj-c++-shared/TestsuiteObject.m"
7
#include "../objc-obj-c++-shared/runtime.h"
8
 
9
#include 
10
#include 
11
 
12
#define CHECK_IF(expr) if(!(expr)) abort()
13
 
14
@class Int1, Int2;
15
struct Nested;
16
 
17
struct Innermost {
18
  unsigned char a, b;
19
  struct Nested *encl;
20
};
21
 
22
struct Nested {
23
  float a, b;
24
  Int1 *next;
25
  struct Innermost innermost;
26
};
27
 
28
@interface Int1: TestsuiteObject {
29
  signed char a, b;
30
  Int2 *int2;
31
  struct Nested nested;
32
}
33
@end
34
 
35
@interface Int2: Int1 {
36
  struct Innermost *innermost;
37
  Int1 *base;
38
}
39
@end
40
 
41
@implementation Int1
42
@end
43
 
44
@implementation Int2
45
@end
46
 
47
#if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
48
struct objc_ivar *ivar;
49
#else
50
Ivar *ivar;
51
#endif
52
 
53
static void check_ivar(const char *name, const char *type) {
54
#if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
55
  CHECK_IF(!strcmp(ivar->ivar_name, name));
56
  CHECK_IF(!strcmp(ivar->ivar_type, type));
57
#else
58
  CHECK_IF(!strcmp(ivar_getName(*ivar), name));
59
  CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
60
#endif
61
  ivar++;
62
}
63
 
64
int main(void) {
65
#if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
66
  ivar = ((Class)objc_getClass("Int1"))->ivars->ivar_list;
67
#else
68
  ivar = class_copyIvarList ((Class)objc_getClass("Int1"), NULL);
69
#endif
70
  check_ivar("a", "c");
71
  check_ivar("b", "c");
72
  check_ivar("int2", "@\"Int2\"");
73
  check_ivar("nested",
74
    "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
75
 
76
#if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE)
77
  ivar = ((Class)objc_getClass("Int2"))->ivars->ivar_list;
78
#else
79
  ivar = class_copyIvarList ((Class)objc_getClass("Int2"), NULL);
80
#endif
81
  check_ivar("innermost", "^{Innermost=CC^{Nested}}");
82
  check_ivar("base", "@\"Int1\"");
83
 
84
  return 0;
85
}
86
 

powered by: WebSVN 2.1.0

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