1 /* Test the -fconstant-string-class=Foo option under the NeXT
3 /* Developed by Markus Hitter <mah@jump-ing.de>. */
5 /* { dg-do run { target *-*-darwin* } } */
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7 /* { dg-options "-fconstant-string-class=Foo" } */
8 /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
9 /* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.mm" } */
11 #import "../../../objc-obj-c++-shared/Object1.h"
12 #import "../../../objc-obj-c++-shared/next-mapping.h"
16 #include <objc/objc.h>
17 #ifndef __NEXT_RUNTIME__
18 #include <objc/objc-api.h>
21 @interface Foo: Object {
25 - (char *)customString;
28 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
29 struct fudge_objc_class _FooClassReference;
31 struct objc_class _FooClassReference;
34 @implementation Foo : Object
35 - (char *)customString {
42 Foo *string2 = @"bla";
46 printf("Strings are being uniqued properly\n");
48 /* This memcpy has to be done before the first message is sent to a
49 constant string object. Can't be moved to +initialize since _that_
50 is already a message. */
52 memcpy(&_FooClassReference, objc_get_class("Foo"), sizeof(_FooClassReference));
53 if (strcmp ([string customString], "bla")) {
57 printf([@"This is a working constant string object\n" customString]);