2010-11-11 Jakub Jelinek <jakub@redhat.com>
[official-gcc.git] / gcc / testsuite / objc.dg / func-ptr-2.m
blobe68c71b70d4c0df594c9c12d67937983d7a9b473
1 /* 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" } { "" } } */
7 #include <stdlib.h>
8 /* provide an Object class for NeXT runtimes 10.5 and above */
9 #include "../objc-obj-c++-shared/Object1.h"
11 @interface Func: Object
12 + (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func;
13 @end
15 @implementation Func
16 + (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func {
17   return func (a, b);
19 @end
21 static int my_computation(int a, int b) {
22   return a * 2 + b * 3;
25 static int processNumber(int a, int b, int func(int, int)) {
26   return func(a, b);
29 int main(void) {
30   int result = processNumber (6, 8, my_computation);
31   if (result != 36)
32     abort ();
34   result = [Func processNumber:8 and:6 usingFunction:my_computation];
35   if (result != 34)
36     abort ();
38   return 0;
41 #include "../objc-obj-c++-shared/Object1-implementation.h"