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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [stret-1.m] - Blame information for rev 797

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

Line No. Rev Author Line
1 704 jeremybenn
/* Test for handling of struct-returning methods.  */
2
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
3
/* { dg-do run } */
4
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5
 
6
#include "../objc-obj-c++-shared/TestsuiteObject.m"
7
 
8
extern void abort(void);
9
#define CHECK_IF(expr) if(!(expr)) abort()
10
 
11
struct astruct {
12
  float a, b;
13
} globa = { 1.0, 2.0 };
14
 
15
struct bstruct {
16
  float a, b, c, d, e, f;
17
} globb = { 1, 2, 3, 4, 5, 6 };
18
 
19
@interface foo : TestsuiteObject
20
- (struct astruct) stret;
21
- (struct bstruct) stretb;
22
@end
23
 
24
@implementation foo : TestsuiteObject
25
- (struct astruct) stret { return globa; }
26
- (struct bstruct) stretb { return globb; }
27
@end
28
 
29
@interface bar: foo
30
- (struct astruct) stret;
31
- (struct bstruct) stretb;
32
@end
33
 
34
@implementation bar
35
- (struct astruct) stret { struct astruct a = [super stret]; a.b = 77; return a; }
36
- (struct bstruct) stretb { struct bstruct b = [super stretb]; b.e = 99; return b; }
37
@end
38
 
39
int main(void)
40
{
41
  foo *obj = [foo new];
42
  bar *obj2 = [bar new];
43
  struct astruct loc, loc2;
44
  struct bstruct locb, locb2;
45
 
46
  loc = [obj stret];
47
  CHECK_IF(loc.a == 1.0 && loc.b == 2.0);
48
 
49
  locb = [obj stretb];
50
  CHECK_IF(locb.f == 6 && locb.c == 3);
51
  CHECK_IF(locb.e == 5 && locb.b == 2);
52
  CHECK_IF(locb.d == 4 && locb.a == 1);
53
 
54
  loc2 = [obj2 stret];
55
  CHECK_IF(loc2.a == 1.0 && loc2.b == 77);
56
 
57
  locb2 = [obj2 stretb];
58
  CHECK_IF(locb2.f == 6 && locb2.c == 3);
59
  CHECK_IF(locb2.e == 99 && locb2.b == 2);
60
  CHECK_IF(locb2.d == 4 && locb2.a == 1);
61
 
62
  return 0;
63
}
64
 

powered by: WebSVN 2.1.0

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