annotate gcc/testsuite/objc.dg/func-ptr-2.m @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Check if method parameters that are functions are gracefully decayed
kono
parents:
diff changeset
2 into pointers. */
kono
parents:
diff changeset
3 /* Contributed by Ziemowit Laski <zlaski@apple.com> */
kono
parents:
diff changeset
4 /* { dg-do run } */
kono
parents:
diff changeset
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 #include <stdlib.h>
kono
parents:
diff changeset
8 #include "../objc-obj-c++-shared/TestsuiteObject.m"
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 @interface Func: TestsuiteObject
kono
parents:
diff changeset
11 + (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func;
kono
parents:
diff changeset
12 @end
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 @implementation Func
kono
parents:
diff changeset
15 + (int) processNumber:(int)a and:(int)b usingFunction:(int(int,int))func {
kono
parents:
diff changeset
16 return func (a, b);
kono
parents:
diff changeset
17 }
kono
parents:
diff changeset
18 @end
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 static int my_computation(int a, int b) {
kono
parents:
diff changeset
21 return a * 2 + b * 3;
kono
parents:
diff changeset
22 }
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 static int processNumber(int a, int b, int func(int, int)) {
kono
parents:
diff changeset
25 return func(a, b);
kono
parents:
diff changeset
26 }
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 int main(void) {
kono
parents:
diff changeset
29 int result = processNumber (6, 8, my_computation);
kono
parents:
diff changeset
30 if (result != 36)
kono
parents:
diff changeset
31 abort ();
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 result = [Func processNumber:8 and:6 usingFunction:my_computation];
kono
parents:
diff changeset
34 if (result != 34)
kono
parents:
diff changeset
35 abort ();
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 return 0;
kono
parents:
diff changeset
38 }
kono
parents:
diff changeset
39