Debian Codegraph @

gcc/testsuite/obj-c++.dg/torture/strings/const-str-8.mm

raw
1 /* Test for assigning compile-time constant-string objects to static variables. */
2 /* Contributed by Ziemowit Laski <[email protected]> */
3
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
8 #include "../../../objc-obj-c++-shared/TestsuiteObject.m"
9 #include <stdlib.h>
10
11 @interface Foo: TestsuiteObject {
12 char *cString;
13 unsigned int len;
14 }
15 @end
16
17 #ifdef __NEXT_RUNTIME__
18 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
19 Class _FooClassReference;
20 #else
21 struct objc_class _FooClassReference;
22 #endif
23 #endif
24
25 @implementation Foo : TestsuiteObject
26 - (char *)customString {
27 return cString;
28 }
29 @end
30
31 static const Foo *appKey = @"MyApp";
32 static int CFPreferencesSynchronize (const Foo *ref) {
33 return ref == appKey;
34 }
35
36 static void PrefsSynchronize(void)
37 {
38 if(!CFPreferencesSynchronize(appKey))
39 abort();
40 }
41
42 int main () {
43 PrefsSynchronize();
44 return 0;
45 }