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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [func-ptr-2.m] - Blame information for rev 309

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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