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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Check if method parameters that are functions are gracefully decayed
2
   into pointers.  */
3
/* Contributed by Ziemowit Laski  <zlaski@apple.com>  */
4
/* { dg-do run } */
5
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6
 
7
#include <stdlib.h>
8
#include "../objc-obj-c++-shared/TestsuiteObject.m"
9
 
10
@interface Func: TestsuiteObject
11
+ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func;
12
@end
13
 
14
@implementation Func
15
+ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func {
16
  return func (a, b);
17
}
18
@end
19
 
20
static int my_computation(int a, int b) {
21
  return a * 2 + b * 3;
22
}
23
 
24
static int processNumber(int a, int b, int func(int, int)) {
25
  return func(a, b);
26
}
27
 
28
int main(void) {
29
  int result = processNumber (6, 8, my_computation);
30
  if (result != 36)
31
    abort ();
32
 
33
  result = [Func processNumber:8 and:6 usingFunction:my_computation];
34
  if (result != 34)
35
    abort ();
36
 
37
  return 0;
38
}
39
 

powered by: WebSVN 2.1.0

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