OSDN Git Service

2010-11-13 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / method-20b.m
1 /* Check if array and function parameters get decayed to pointers as
2    they should.  */
3 /* { dg-do run } */
4 /* { dg-options "-O2" } */
5 /* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7
8 #include "../objc-obj-c++-shared/Object1.h"
9 #include <string.h>
10 #include <stdlib.h>
11
12 static char global_buf[20];
13
14 char *strcpy_like_callee(const char *s) {
15   strcpy(global_buf, s);
16   return global_buf;
17 }  
18
19 typedef char io_string_t[512];
20 typedef char *(func_type)(const char *);
21
22 @interface DeviceObject: Object
23 - (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath;
24 @end
25 @implementation DeviceObject
26 - (void) func:(func_type)func stucPathInIORegistry:(io_string_t)ioRegPath
27 {
28     func(ioRegPath);
29 }
30 @end
31
32 int main (void) {
33   io_string_t my_string;
34   DeviceObject *obj = [DeviceObject new];
35
36   strcpy (my_string, "Hello!");
37   strcpy (global_buf, "Good-bye!");
38
39   [obj func:strcpy_like_callee stucPathInIORegistry:my_string];
40
41   if (strcmp (global_buf, "Hello!"))
42     abort ();
43
44   return 0;
45 }