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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [proto-qual-1.m] - Blame information for rev 318

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

Line No. Rev Author Line
1 309 jeremybenn
/* Check that protocol qualifiers are compiled and encoded properly.  */
2
/* Author: 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/Protocol1.h"
8
#ifndef __NEXT_RUNTIME__
9
#include <objc/objc-api.h>
10
#endif
11
 
12
/* The encoded parameter sizes will be rounded up to match pointer alignment.  */
13
#define ROUND(s,a) (a * ((s + a - 1) / a))
14
#define aligned_sizeof(T) ROUND(sizeof(T),__alignof(void *))
15
 
16
extern int sscanf(const char *str, const char *format, ...);
17
extern void abort(void);
18
#define CHECK_IF(expr) if(!(expr)) abort()
19
 
20
@protocol Retain
21
+ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2;
22
- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2;
23
@end
24
 
25
@interface Foo <Retain>
26
+ (oneway void)retainArgument:(out bycopy id)arg with:(in signed char **)arg2;
27
@end
28
 
29
@implementation Foo
30
+ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2 { }
31
- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2 { return nil; }
32
@end
33
 
34
Protocol *proto = @protocol(Retain);
35
struct objc_method_description *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->types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3,
41
      &offs4, &offs5, &offs6, &offs7);
42
  CHECK_IF(!offs0 && offs1 == aligned_sizeof(id) && offs2 == offs1 + aligned_sizeof(SEL) && totsize >= offs2);
43
}
44
 
45
int main(void) {
46
  meth = [proto descriptionForInstanceMethod: @selector(address:with:)];
47
  scan_initial("O@%u@%u:%uRN@%uo^^S%u");
48
  CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 + aligned_sizeof(unsigned));
49
  meth = [proto descriptionForClassMethod: @selector(retainArgument:with:)];
50
  scan_initial("Vv%u@%u:%uoO@%un^*%u");
51
  CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 + aligned_sizeof(char **));
52
  return 0;
53
}

powered by: WebSVN 2.1.0

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