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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [type-size-2.m] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Make sure that array arguments to methods are given the size of pointers.  */
2
/* As in the case of ivars, arrays without size (e.g., 'int []') are
3
   encoded as pointers.  */
4
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
5
/* { dg-do run } */
6
 
7
#include <objc/objc.h>
8
#ifdef __NEXT_RUNTIME__
9
#include <objc/objc-runtime.h>
10
#define OBJC_GETCLASS objc_getClass
11
#define CLASS_GETINSTANCEMETHOD class_getInstanceMethod
12
#else
13
#include <objc/objc-api.h>
14
#define OBJC_GETCLASS objc_get_class
15
#define CLASS_GETINSTANCEMETHOD class_get_instance_method
16
#endif
17
 
18
extern int sscanf(const char *str, const char *format, ...);
19
extern void abort(void);
20
#define CHECK_IF(expr) if(!(expr)) abort()
21
 
22
enum Enum { one, two, three, four };
23
 
24
@interface ArrayTest
25
- (const char *)str:(signed char [])arg1 with:(unsigned char *)arg2 and:(enum Enum[4])en;
26
- (int)meth1:(int [])arg1 with:(int [0])arg2 with:(int [2])arg3;
27
@end
28
 
29
@implementation ArrayTest
30
- (int)meth1:(int [])arg1 with:(int [0])arg2 with:(int [2])arg3 { return 0; }
31
- (const char *)str:(signed char [])arg1 with:(unsigned char *)arg2 and:(enum Enum[4])en { return "str"; }
32
@end
33
 
34
Class cls;
35
struct objc_method *meth;
36
unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7;
37
 
38
static void scan_initial(const char *pattern) {
39
  totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1;
40
  sscanf(meth->method_types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3,
41
      &offs4, &offs5, &offs6, &offs7);
42
  CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 + sizeof(SEL) && totsize >= offs2);
43
}
44
 
45
int main(void) {
46
  cls = OBJC_GETCLASS("ArrayTest");
47
 
48
  meth = CLASS_GETINSTANCEMETHOD(cls, @selector(str:with:and:));
49
  scan_initial("r*%u@%u:%u*%u*%u[4i]%u");
50
  CHECK_IF(offs3 == offs2 + sizeof(signed char *) && offs4 == offs3 + sizeof(unsigned char *));
51
  CHECK_IF(totsize == offs4 + sizeof(enum Enum *));
52
  meth = CLASS_GETINSTANCEMETHOD(cls, @selector(meth1:with:with:));
53
  scan_initial("i%u@%u:%u^i%u[0i]%u[2i]%u");
54
  CHECK_IF(offs3 == offs2 + sizeof(int *) && offs4 == offs3 + sizeof(int *));
55
  CHECK_IF(totsize == offs4 + sizeof(int *));
56
  return 0;
57
}
58
 

powered by: WebSVN 2.1.0

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