1 /* Test the -fconstant-string-class=Foo option under the NeXT
3 /* Developed by Markus Hitter <mah@jump-ing.de>. */
5 /* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
6 /* { dg-do run { target *-*-darwin* } } */
10 #include <objc/Object.h>
12 @interface Foo: Object {
16 - (char *)customString;
19 struct objc_class _FooClassReference;
21 @implementation Foo : Object
22 - (char *)customString {
29 Foo *string2 = @"bla";
33 printf("Strings are being uniqued properly\n");
35 /* This memcpy has to be done before the first message is sent to a
36 constant string object. Can't be moved to +initialize since _that_
37 is already a message. */
39 memcpy(&_FooClassReference, objc_getClass("Foo"), sizeof(_FooClassReference));
40 if (strcmp ([string customString], "bla")) {
44 printf([@"This is a working constant string object\n" customString]);