Merged r157653 through r157895 into branch.
[official-gcc.git] / gcc / testsuite / objc.dg / const-str-8.m
bloba7da0e102760c2dfd62ad56d380194c24788c1d9
1 /* Test for assigning compile-time constant-string objects to static variables.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
3 /* { dg-options "-fconstant-string-class=Foo" } */
4 /* { dg-do run } */
6 #include "../objc-obj-c++-shared/Object1.h"
7 #include <stdlib.h>
9 @interface Foo: Object {
10   char *cString;
11   unsigned int len;
13 @end
15 #ifndef NEXT_OBJC_USE_NEW_INTERFACE
16 struct objc_class _FooClassReference;
17 #else
18 Class _FooClassReference;
19 #endif
21 @implementation Foo : Object
22 - (char *)customString {
23   return cString;
25 @end
27 static const Foo *appKey = @"MyApp";
28 static int CFPreferencesSynchronize (const Foo *ref) {
29   return ref == appKey;
32 static void PrefsSynchronize(void)
34   if(!CFPreferencesSynchronize(appKey))
35     abort();
38 int main () {
39   PrefsSynchronize();
40   return 0;
43 #include "../objc-obj-c++-shared/Object1-implementation.h"