OSDN Git Service

* obj-c++.dg/comp-types-10.mm: XFAIL for ICE.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / const-str-8.mm
1 /* Test for assigning compile-time constant-string objects to static variables.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
3
4 /* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
5 /* { dg-do run { target *-*-darwin* } } */
6
7
8 #include <stdlib.h>
9 #include <objc/Object.h>
10
11 @interface Foo: Object {
12   char *cString;
13   unsigned int len;
14 }
15 @end
16
17 struct objc_class _FooClassReference;
18
19 @implementation Foo : Object
20 - (char *)customString {
21   return cString;
22 }
23 @end
24
25 static const Foo *appKey = @"MyApp";
26 static int CFPreferencesSynchronize (const Foo *ref) {
27   return ref == appKey;
28 }
29
30 static void PrefsSynchronize(void)
31 {
32   if(!CFPreferencesSynchronize(appKey))
33     abort();
34 }
35
36 int main () {
37   PrefsSynchronize();
38   return 0;
39 }