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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 704 jeremybenn
/* Test for handling of function pointer ivars */
2
/* { dg-do run } */
3
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
 
5
#include "../objc-obj-c++-shared/TestsuiteObject.m"
6
 
7
extern int strcmp(const char *, const char *);
8
extern void abort(void);
9
#define CHECK_IF(expr) if(!(expr)) abort()
10
 
11
typedef float (*floatfunc)(float, float);
12
 
13
@interface MyObject : TestsuiteObject
14
{
15
@public
16
  int (*ivar)(int, int, int);
17
  floatfunc ffunc;
18
}
19
- init;
20
@end
21
 
22
int foo(int a, int b, int c) {
23
  return a + b + c;
24
}
25
 
26
float bar(float a, float b) {
27
  return a * b;
28
}
29
 
30
@implementation MyObject
31
- init {
32
  [super init];
33
  ivar = foo;
34
  ffunc = bar;
35
  return self;
36
}
37
@end
38
 
39
int main ()
40
{
41
  MyObject *obj = [[MyObject alloc] init];
42
  const char *enc = @encode(MyObject);
43
 
44
  CHECK_IF(obj->ivar(4, 5, 6) == 15);
45
  CHECK_IF(obj->ffunc(34.0, 45.0) == 34.0 * 45.0);
46
  CHECK_IF(!strcmp(enc, "{MyObject=#^?^?}"));
47
  return(0);
48
}
49
 

powered by: WebSVN 2.1.0

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