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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [obj-c++.dg/] [encode-5.mm] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 308 jeremybenn
/* Method encoding tests for stand-alone @protocol declarations.  */
2
/* Contributed by Ziemowit Laski .  */
3
/* { dg-do run } */
4
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5
#include "../objc-obj-c++-shared/Object1.h"
6
#include "../objc-obj-c++-shared/next-mapping.h"
7
#include "../objc-obj-c++-shared/Protocol1.h"
8
#ifdef __cplusplus
9
#define ProtoBool bool
10
#else
11
#define ProtoBool _Bool
12
#endif
13
 
14
#ifdef __NEXT_RUNTIME__
15
#define METHOD Method
16
#else
17
#include 
18
#define METHOD Method_t
19
#define method_get_types(M) (M)->method_types
20
#endif
21
 
22
#include 
23
#include 
24
 
25
#define CHECK_IF(expr) if(!(expr)) abort()
26
 
27
enum Enum {
28
  zero, one, two, three
29
};
30
typedef enum Enum Enum;
31
typedef signed char ObjCBool; /* as used by the NeXT runtime */
32
 
33
@protocol Proto
34
union __XXAngle { unsigned int alpha, beta; };
35
typedef struct { float x, y; union __XXAngle a; } XXPoint;
36
typedef struct { double width, height; } XXSize;
37
typedef struct _XXRect { XXPoint origin; XXSize size; struct _XXRect *next; } XXRect;
38
- (void) char:(signed char)c float:(float)f double:(double)d unsigned:(unsigned)u short:(short)s long:(long)l;
39
- (void *)setRect:(XXRect)r withBool:(ProtoBool)b withInt:(int)i;
40
+ (Enum *)getEnum:(XXPoint *)pt enum:(enum Enum)e bool:(ObjCBool)b;
41
+ (ProtoBool **)getBool:(ObjCBool **)b;
42
@end
43
 
44
Protocol *proto = @protocol(Proto);
45
struct objc_method_description *meth;
46
 
47
unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7;
48
 
49
static void scan_initial(const char *pattern) {
50
  totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1;
51
  sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3,
52
      &offs4, &offs5, &offs6, &offs7);
53
  CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 + sizeof(SEL) && totsize >= offs2);
54
}
55
 
56
int main(void) {
57
  const char *string;
58
 
59
  meth = [proto descriptionForInstanceMethod: @selector(char:float:double:unsigned:short:long:)];
60
  if (sizeof (long) == 8)
61
    string = "v%u@%u:%uc%uf%ud%uI%us%uq%u";
62
  else
63
    string = "v%u@%u:%uc%uf%ud%uI%us%ul%u";
64
  scan_initial(string);
65
  CHECK_IF(offs3 == offs2 + sizeof(int) && offs4 == offs3 + sizeof(float));
66
  CHECK_IF(offs5 == offs4 + sizeof(double) && offs6 == offs5 + sizeof(unsigned));
67
  CHECK_IF(offs7 == offs6 + sizeof(int) && totsize == offs7 + sizeof(long));
68
  meth = [proto descriptionForInstanceMethod: @selector(setRect:withBool:withInt:)];
69
  scan_initial("^v%u@%u:%u{_XXRect={?=ff(__XXAngle=II)}{?=dd}^{_XXRect}}%uB%ui%u");
70
  CHECK_IF(offs3 == offs2 + sizeof(XXRect) && offs4 == offs3 + sizeof(int));
71
  CHECK_IF(totsize == offs4 + sizeof(int));
72
  meth = [proto descriptionForClassMethod: @selector(getEnum:enum:bool:)];
73
  scan_initial("^i%u@%u:%u^{?=ff(__XXAngle=II)}%ui%uc%u");
74
  CHECK_IF(offs3 == offs2 + sizeof(XXPoint *) && offs4 == offs3 + sizeof(enum Enum));
75
  CHECK_IF(totsize == offs4 + sizeof(int));  /* 'ObjCBool' is really 'char' */
76
  meth = [proto descriptionForClassMethod: @selector(getBool:)];
77
  scan_initial("^^B%u@%u:%u^*%u");
78
  CHECK_IF(totsize == offs2 + sizeof(ObjCBool **));
79
  return 0;
80
}
81
#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.