Merged r157653 through r157895 into branch.
[official-gcc.git] / gcc / testsuite / obj-c++.dg / const-str-8.mm
blob67473417f29358f2707f913bb9cd885b587d6b4d
1 /* Test for assigning compile-time constant-string objects to static variables.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
4 /* { dg-options "-fconstant-string-class=Foo" } */
5 /* { dg-do run { target *-*-darwin* } } */
7 #include "../objc-obj-c++-shared/Object1.h"
8 #include <stdlib.h>
10 @interface Foo: Object {
11   char *cString;
12   unsigned int len;
14 @end
16 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
17 Class _FooClassReference;
18 #else
19 struct objc_class _FooClassReference;
20 #endif
22 @implementation Foo : Object
23 - (char *)customString {
24   return cString;
26 @end
28 static const Foo *appKey = @"MyApp";
29 static int CFPreferencesSynchronize (const Foo *ref) {
30   return ref == appKey;
33 static void PrefsSynchronize(void)
35   if(!CFPreferencesSynchronize(appKey))
36     abort();
39 int main () {
40   PrefsSynchronize();
41   return 0;
44 #include "../objc-obj-c++-shared/Object1-implementation.h"