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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [func-ptr-1.m] - Blame information for rev 844

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

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

powered by: WebSVN 2.1.0

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