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.5.1/] [gcc/] [testsuite/] [obj-c++.dg/] [encode-6.mm] - Blame information for rev 484

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

Line No. Rev Author Line
1 308 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/Object1.h"
7
#include "../objc-obj-c++-shared/next-mapping.h"
8
#ifndef __NEXT_RUNTIME__
9
#include 
10
#endif
11
 
12
#include 
13
#include 
14
 
15
#define CHECK_IF(expr) if(!(expr)) abort()
16
 
17
@class Int1, Int2;
18
struct Nested;
19
 
20
struct Innermost {
21
  unsigned char a, b;
22
  struct Nested *encl;
23
};
24
 
25
struct Nested {
26
  float a, b;
27
  Int1 *next;
28
  struct Innermost innermost;
29
};
30
 
31
@interface Int1: Object {
32
  signed char a, b;
33
  Int2 *int2;
34
  struct Nested nested;
35
}
36
@end
37
 
38
@interface Int2: Int1 {
39
  struct Innermost *innermost;
40
  Int1 *base;
41
}
42
@end
43
 
44
@implementation Int1
45
@end
46
 
47
@implementation Int2
48
@end
49
 
50
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
51
Ivar *ivar;
52
#else
53
struct objc_ivar *ivar;
54
#endif
55
 
56
static void check_ivar(const char *name, const char *type) {
57
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
58
  CHECK_IF(!strcmp(ivar_getName(*ivar), name));
59
  CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
60
#else
61
  CHECK_IF(!strcmp(ivar->ivar_name, name));
62
  CHECK_IF(!strcmp(ivar->ivar_type, type));
63
#endif
64
  ivar++;
65
}
66
 
67
int main(void) {
68
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
69
  ivar = class_copyIvarList ((Class)objc_get_class("Int1"), NULL);
70
#else
71
  ivar = ((Class)objc_get_class("Int1"))->ivars->ivar_list;
72
#endif
73
  check_ivar("a", "c");
74
  check_ivar("b", "c");
75
  check_ivar("int2", "@\"Int2\"");
76
  check_ivar("nested",
77
    "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
78
 
79
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
80
  ivar = class_copyIvarList ((Class)objc_get_class("Int2"), NULL);
81
#else
82
  ivar = ((Class)objc_get_class("Int2"))->ivars->ivar_list;
83
#endif
84
  check_ivar("innermost", "^{Innermost=CC^{Nested}}");
85
  check_ivar("base", "@\"Int1\"");
86
 
87
  return 0;
88
}
89
#include "../objc-obj-c++-shared/Object1-implementation.h"

powered by: WebSVN 2.1.0

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