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* } } */
11 #include <objc/objc.h>
12 #include <objc/Object.h>
14 @interface Foo: Object {
18 - (char *)customString;
21 struct objc_class _FooClassReference;
23 @implementation Foo : Object
24 - (char *)customString {
31 Foo *string2 = @"bla";
35 printf("Strings are being uniqued properly\n");
37 /* This memcpy has to be done before the first message is sent to a
38 constant string object. Can't be moved to +initialize since _that_
39 is already a message. */
41 memcpy(&_FooClassReference, objc_getClass("Foo"), sizeof(_FooClassReference));
42 if (strcmp ([string customString], "bla")) {
46 printf([@"This is a working constant string object\n" customString]);