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-2.m] - Blame information for rev 827

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

Line No. Rev Author Line
1 149 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
 
6
#include <objc/Object.h>
7
#include <stdlib.h>
8
 
9
@interface Func: Object
10
+ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func;
11
@end
12
 
13
@implementation Func
14
+ (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func {
15
  return func (a, b);
16
}
17
@end
18
 
19
static int my_computation(int a, int b) {
20
  return a * 2 + b * 3;
21
}
22
 
23
static int processNumber(int a, int b, int func(int, int)) {
24
  return func(a, b);
25
}
26
 
27
int main(void) {
28
  int result = processNumber (6, 8, my_computation);
29
  if (result != 36)
30
    abort ();
31
 
32
  result = [Func processNumber:8 and:6 usingFunction:my_computation];
33
  if (result != 34)
34
    abort ();
35
 
36
  return 0;
37
}

powered by: WebSVN 2.1.0

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