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