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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [objc.dg/] [encode-4.m] - Blame information for rev 309

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

Line No. Rev Author Line
1 309 jeremybenn
/* Encoding tests for ObjC class layouts.  */
2
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
3
/* { dg-options "" } */
4
/* { dg-do run } */
5
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6
 
7
#include "../objc-obj-c++-shared/Object1.h"
8
#include "../objc-obj-c++-shared/next-mapping.h"
9
#ifdef __NEXT_RUNTIME__
10
#include <objc/objc-class.h>
11
#else
12
#include <objc/objc-api.h>
13
#endif
14
 
15
extern void abort(void);
16
extern int strcmp(const char *s1, const char *s2);
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
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
54
Ivar *ivar;
55
#else
56
struct objc_ivar *ivar;
57
#endif
58
 
59
static void check_ivar(const char *name, const char *type) {
60
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
61
  CHECK_IF(!strcmp(ivar_getName(*ivar), name));
62
  CHECK_IF(!strcmp(ivar_getTypeEncoding(*ivar), type));
63
#else
64
  CHECK_IF(!strcmp(ivar->ivar_name, name));
65
  CHECK_IF(!strcmp(ivar->ivar_type, type));
66
#endif
67
  ivar++;
68
}
69
 
70
int main(void) {
71
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
72
  ivar = class_copyIvarList ((Class)objc_get_class("Int1"), NULL);
73
#else
74
  ivar = ((Class)objc_get_class("Int1"))->ivars->ivar_list;
75
#endif
76
  check_ivar("a", "c");
77
  check_ivar("b", "c");
78
  check_ivar("int2", "@\"Int2\"");
79
  check_ivar("nested",
80
    "{Nested=\"a\"f\"b\"f\"next\"@\"Int1\"\"innermost\"{Innermost=\"a\"C\"b\"C\"encl\"^{Nested}}}");
81
 
82
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
83
  ivar = class_copyIvarList ((Class)objc_get_class("Int2"), NULL);
84
#else
85
  ivar = ((Class)objc_get_class("Int2"))->ivars->ivar_list;
86
#endif
87
  check_ivar("innermost", "^{Innermost=CC^{Nested}}");
88
  check_ivar("base", "@\"Int1\"");
89
 
90
  return 0;
91
}
92
 
93
#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.