Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc.dg / torture / strings / const-str-8.m
blobc5bacaf437f19a34d51d432f459e5acbe276ebe1
1 /* Test for assigning compile-time constant-string objects to static variables.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
3 /* { dg-do run } */
4 /* { dg-options "-fconstant-string-class=Foo" } */
5 /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
6 /* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
8 #include "../../../objc-obj-c++-shared/Object1.h"
9 #include <stdlib.h>
11 @interface Foo: Object {
12   char *cString;
13   unsigned int len;
15 @end
17 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
18 Class _FooClassReference;
19 #else
20 struct objc_class _FooClassReference;
21 #endif
23 @implementation Foo : Object
24 - (char *)customString {
25   return cString;
27 @end
29 static const Foo *appKey = @"MyApp";
30 static int CFPreferencesSynchronize (const Foo *ref) {
31   return ref == appKey;
34 static void PrefsSynchronize(void)
36   if(!CFPreferencesSynchronize(appKey))
37     abort();
40 int main () {
41   PrefsSynchronize();
42   return 0;