+2010-10-21 Iain Sandoe <iains@gcc.gnu.org>
+
+ Based on the CFString implementation in FSF apple/trunk branch.
+
+ * lib/objc-dg.exp (objc-dg-runtest): Merge flags and additional flags
+ so that the latter can be used in dg-skip and dg-xfail clauses.
+ * lib/obj-c++-dg.exp (obj-c++-dg-runtest): Likewise.
+ * obj-c++.dg/template-4.mm: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1.
+ * obj-c++.dg/const-str-7.mm: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1, move to torture/strings/.
+ * obj-c++.dg/const-str-4.mm: Likewise.
+ * obj-c++.dg/const-str-3.mm: Likewise.
+ * obj-c++.dg/const-str-8.mm: Likewise.
+ * obj-c++.dg/const-str-9.mm: Likewise.
+ * obj-c++.dg/const-str-10.mm: Likewise.
+ * obj-c++.dg/const-str-10.mm: Likewise.
+ * obj-c++.dg/const-str-1.mm: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1, move to strings/.
+ * obj-c++.dg/const-str-2.mm: Likewise.
+ * obj-c++.dg/const-str-5.mm: Likewise.
+ * obj-c++.dg/const-str-6.mm: Likewise.
+ * obj-c++.dg/const-str-12.mm: Likewise.
+ * obj-c++.dg/strings/strings.exp: New.
+ * obj-c++.dg/strings/const-cfstring-2.mm: New.
+ * obj-c++.dg/strings/const-cfstring-5.mm: New.
+ * obj-c++.dg/torture/strings/strings.exp: New.
+ * obj-c++.dg/torture/strings/string1.mm: New.
+ * obj-c++.dg/torture/strings/const-cfstring-1.mm: New.
+ * obj-c++.dg/torture/strings/const-cfstring-3.mm: New.
+ * obj-c++.dg/torture/strings/const-cfstring-4.mm: New.
+
+ * objc/execute/string1.m: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1, move to objc.dg/torture/strings/.
+ * objc/execute/string2.m: Likewise.
+ * objc/execute/string3.m: Likewise.
+ * objc/execute/string3.m: Likewise.
+ * objc.dg/foreach-2.m: Don't use CFStrings on Darwin.
+ * objc.dg/foreach-4.m: Likewise.
+ * objc.dg/foreach-5.m: Likewise.
+ * objc.dg/const-str-3.m: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1, move to objc.dg/torture/strings/.
+ * objc.dg/const-str-4.m: Likewise.
+ * objc.dg/const-str-7.m: Likewise.
+ * objc.dg/const-str-8.m: Likewise.
+ * objc.dg/const-str-9.m: Likewise.
+ * objc.dg/const-str-10.m: Likewise.
+ * objc.dg/const-str-11.m: Likewise.
+ * objc.dg/const-str-1.m: Don't use CFStrings on Darwin. Update test
+ to use dg-additional-files for Object1, move to objc.dg/strings/.
+ * objc.dg/const-str-2.m: Likewise.
+ * objc.dg/const-str-5.m: Likewise.
+ * objc.dg/const-str-6.m: Likewise.
+ * objc.dg/const-str-12.m: Likewise.
+ * objc.dg/const-str-12b.m: Likewise.
+ * objc.dg/strings/strings.exp: New.
+ * objc.dg/strings/const-cfstring-2.m: New.
+ * objc.dg/strings/const-cfstring-5.m: New.
+ * objc.dg/torture/strings/strings.exp: New.
+ * objc.dg/torture/strings/const-cfstring-1.m: New.
+ * objc.dg/torture/strings/const-cfstring-3.m: New.
+ * objc.dg/torture/strings/const-cfstring-4.m: New.
+
2010-10-22 Marcus Shawcroft <marcus.shawcroft@arm.com>
* gcc.target/arm/synchronize.c: Permit dmb or mcr in assembler scan.
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc obj-c++-dg-runtest { testcases default-extra-flags } {
- return [gcc-dg-runtest $testcases ${default-extra-flags}]
-}
+ global runtests
+
+ # Some callers set torture options themselves; don't override those.
+ set existing_torture_options [torture-options-exist]
+ if { $existing_torture_options == 0 } {
+ global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
+ torture-init
+ set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
+ }
+ dump-torture-options
+
+ foreach test $testcases {
+ global torture_with_loops torture_without_loops
+ # If we're only testing specific files and this isn't one of
+ # them, skip it.
+ if ![runtest_file_p $runtests $test] {
+ continue
+ }
+
+ # Look for a loop within the source code - if we don't find one,
+ # don't pass -funroll[-all]-loops.
+ if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
+ set option_list $torture_with_loops
+ } else {
+ set option_list $torture_without_loops
+ }
+
+ set nshort [file tail [file dirname $test]]/[file tail $test]
+
+ foreach flags $option_list {
+ # combine flags so that dg-skip & xfail will see the extras.
+ set combined_flags "$flags ${default-extra-flags}"
+ verbose "Testing $nshort, $combined_flags" 1
+ dg-test $test $combined_flags ""
+ }
+ }
+
+ if { $existing_torture_options == 0 } {
+ torture-finish
+ }
+}
\ No newline at end of file
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc objc-dg-runtest { testcases default-extra-flags } {
- return [gcc-dg-runtest $testcases ${default-extra-flags}]
+ global runtests
+
+ # Some callers set torture options themselves; don't override those.
+ set existing_torture_options [torture-options-exist]
+ if { $existing_torture_options == 0 } {
+ global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
+ torture-init
+ set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
+ }
+ dump-torture-options
+
+ foreach test $testcases {
+ global torture_with_loops torture_without_loops
+ # If we're only testing specific files and this isn't one of
+ # them, skip it.
+ if ![runtest_file_p $runtests $test] {
+ continue
+ }
+
+ # Look for a loop within the source code - if we don't find one,
+ # don't pass -funroll[-all]-loops.
+ if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
+ set option_list $torture_with_loops
+ } else {
+ set option_list $torture_without_loops
+ }
+
+ set nshort [file tail [file dirname $test]]/[file tail $test]
+
+ foreach flags $option_list {
+ # combine flags so that dg-skip & xfail will see the extras.
+ set combined_flags "$flags ${default-extra-flags}"
+ verbose "Testing $nshort, $combined_flags" 1
+ dg-test $test $combined_flags ""
+ }
+ }
+
+ if { $existing_torture_options == 0 } {
+ torture-finish
+ }
}
--- /dev/null
+/* Test the -Wnonportable-cfstrings option, which should give
+ warnings if non-ASCII characters are embedded in constant
+ CFStrings. This will only work on MacOS X 10.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -Wnonportable-cfstrings" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+
+#ifndef __CONSTANT_CFSTRINGS__
+#error The -fconstant-cfstrings option is not functioning properly
+#endif
+
+void foo(void) {
+ NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+ NSString *s3 = @"Non-ASCII literal - \222"; /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s4 = CFSTR("\222 - Non-ASCII literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s5 = CFSTR("Non-ASCII (\222) literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ NSString *s6 = @"\0Embedded NUL"; /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s7 = CFSTR("Embedded \0NUL"); /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s8 = CFSTR("Embedded NUL\0"); /* { dg-warning "embedded NUL in CFString literal" } */
+}
--- /dev/null
+/* Test if constant CFStrings may be passed back as ObjC strings. */
+/* Author: Ziemowit Laski */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings" } */
+
+#include <objc/Object.h>
+
+@interface Foo: Object {
+ char *cString;
+ unsigned int len;
+}
++ (Foo *)description;
+@end
+
+@interface Bar: Object
++ (Foo *) getString: (int) which;
+@end
+
+@implementation Bar
++ (Foo *) getString: (int) which {
+ return which? [Foo description]: @"Hello";
+}
+@end
/* Test errors for constant strings. */
/* { dg-do compile } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
#ifdef __cplusplus
extern void baz(...);
/* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
-#import "../objc-obj-c++-shared/next-mapping.h"
+#include "../../objc-obj-c++-shared/Object1.h"
@interface Foo: Object {
char *cString;
@end
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
-struct fudge_objc_class _FooClassReference;
+Class _FooClassReference;
#else
struct objc_class _FooClassReference;
#endif
/* Test the -fconstant-string-class flag error. */
/* { dg-do compile } */
/* { dg-options "-fconstant-string-class=" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=" { target *-*-darwin* } } */
{ dg-error "no class name specified|missing argument" "" { target *-*-* } 0 }
/* Positive test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=MyConstantString" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase {
const char *p;
/* Negative test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=MyConstantString" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase {
char p;
--- /dev/null
+# String tests that only need to run at default optimization.
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Load support procs.
+load_lib obj-c++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_OBJCXXFLAGS
+if ![info exists DEFAULT_OBJCXXFLAGS] then {
+ set DEFAULT_OBJCXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
+
+# Main loop.
+dg-runtest $tests "-fgnu-runtime" $DEFAULT_OBJCXXFLAGS
+
+# darwin targets can also run code with the NeXT runtime.
+if [istarget "*-*-darwin*" ] {
+ dg-runtest $tests "-fnext-runtime" $DEFAULT_OBJCXXFLAGS
+}
+
+# All done.
+dg-finish
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-additional-sources "../objc-obj-c++-shared/Object1.mm" } */
+
#include "../objc-obj-c++-shared/Object1.h"
#include "../objc-obj-c++-shared/next-mapping.h"
#include <stdarg.h>
CHECK_IF(abc(a1, a2) * t.k == 35);
return 0;
}
-#include "../objc-obj-c++-shared/Object1-implementation.h"
--- /dev/null
+/* Test the -fconstant-cfstrings option for constructing
+ compile-time immutable CFStrings, and their interoperation
+ with both Cocoa and CoreFoundation. This will only work
+ on MacOS X 10.1.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -framework Cocoa" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+#include <stdlib.h>
+
+void printOut(NSString *str) {
+ NSLog(@"The value of str is: %@", str);
+}
+
+CFStringRef s0a = CFSTR("Compile-time string literal");
+CFStringRef s0b = CFSTR("Compile-time string literal");
+
+void checkNSRange(NSRange r) {
+ if (r.location != 6 || r.length != 5) {
+ printOut(@"Range check failed");
+ abort();
+ }
+}
+
+void checkCFRange(CFRange r) {
+ if (r.location != 6 || r.length != 5) {
+ printOut(@"Range check failed");
+ abort();
+ }
+}
+
+int main(void) {
+ const NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+
+ checkNSRange([@"Hello World" rangeOfString:@"World"]);
+ checkNSRange([(id)CFSTR("Hello World") rangeOfString:@"World"]);
+ checkNSRange([@"Hello World" rangeOfString:(id)CFSTR("World")]);
+ checkNSRange([(id)CFSTR("Hello World") rangeOfString:(id)CFSTR("World")]);
+
+ checkCFRange(CFStringFind((CFStringRef)@"Hello World", (CFStringRef)@"World", 0));
+ checkCFRange(CFStringFind(CFSTR("Hello World"), (CFStringRef)@"World", 0));
+ checkCFRange(CFStringFind((CFStringRef)@"Hello World", CFSTR("World"), 0));
+ checkCFRange(CFStringFind(CFSTR("Hello World"), CFSTR("World"), 0));
+
+ /* Check for string uniquing. */
+ if (s0a != s0b || s0a != s2 || s1 != (id)s2) {
+ NSLog(@"String uniquing failed");
+ abort ();
+ }
+
+ return 0;
+}
--- /dev/null
+/* Test for assigning compile-time constant-string objects to static variables. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com> */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -framework Foundation" } */
+
+#include <stdlib.h>
+
+typedef const struct __CFString * CFStringRef;
+static CFStringRef appKey = (CFStringRef) @"com.apple.soundpref";
+
+static int CFPreferencesSynchronize (CFStringRef ref) {
+ return ref == appKey;
+}
+
+static void PrefsSynchronize()
+{
+ if(!CFPreferencesSynchronize(appKey))
+ abort();
+}
+
+int main(void) {
+ PrefsSynchronize();
+ return 0;
+}
--- /dev/null
+/* Test if constant CFStrings get placed in the correct section and that the
+ layout of the object is correct for both m32 and m64. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com> */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings" } */
+
+typedef const struct __CFString * CFStringRef;
+static CFStringRef appKey = (CFStringRef) @"com.apple.soundpref";
+
+void *foo (void)
+{
+ void *a = (void *)appKey;
+ return a;
+}
+
+/* { dg-final { scan-assembler ".section __DATA, __cfstring" } } */
+/* { dg-final { scan-assembler ".long\t___CFConstantStringClassReference\n\t.long\t1992\n\t.long\t.*\n\t.long\t19\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t19\n" { target { *-*-darwin* && { lp64 } } } } } */
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface NSString: Object
@end
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-fconstant-string-class=XStr" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=XStr" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface XString: Object {
@protected
}
@end
-#ifndef NEXT_OBJC_USE_NEW_INTERFACE
-extern struct objc_class _XStrClassReference;
-#else
+#ifdef NEXT_OBJC_USE_NEW_INTERFACE
extern Class _XStrClassReference;
+#else
+extern struct objc_class _XStrClassReference;
#endif
const XStr *appKey = @"MyApp";
runtime. */
/* Developed by Markus Hitter <mah@jump-ing.de>. */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run { target *-*-darwin* } } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.mm" } */
-#import "../objc-obj-c++-shared/Object1.h"
-#import "../objc-obj-c++-shared/next-mapping.h"
+#import "../../../objc-obj-c++-shared/Object1.h"
+#import "../../../objc-obj-c++-shared/next-mapping.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
printf([@"This is a working constant string object\n" customString]);
return 0;
}
-#include "../objc-obj-c++-shared/Object1-implementation.h"
+
/* Ensure that the preprocessor handles ObjC string constants gracefully. */
/* Author: Ziemowit Laski <zlaski@apple.com> */
-/* { dg-options "-fconstant-string-class=MyString" } */
+
/* { dg-do run { target *-*-darwin* } } */
+/* { dg-options "-fconstant-string-class=MyString" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyString" { target *-*-darwin* } } */
#include <stdlib.h>
scopes. */
/* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run } */
-/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.mm" } */
-#include "../objc-obj-c++-shared/Object1.h"
-#include "../objc-obj-c++-shared/next-mapping.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@end
#ifdef NEXT_OBJC_USE_NEW_INTERFACE
-struct fudge_objc_class _FooClassReference;
+Class _FooClassReference;
#else
struct objc_class _FooClassReference;
#endif
}
return 0;
}
-#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Test for assigning compile-time constant-string objects to static variables. */
/* Contributed by Ziemowit Laski <zlaski@apple.com> */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run { target *-*-darwin* } } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.mm" } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
#include <stdlib.h>
@interface Foo: Object {
PrefsSynchronize();
return 0;
}
-
-#include "../objc-obj-c++-shared/Object1-implementation.h"
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface NSConstantString: Object {
char *cString;
--- /dev/null
+/* Based on a test case contributed by Nicola Pero. */
+
+/* { dg-do run } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.mm" } */
+
+#include "../../../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/next-mapping.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef __NEXT_RUNTIME__
+#include <objc/NXConstStr.h>
+#endif
+
+int main(int argc, char **args)
+{
+ if (strcmp ([@"this is a string" cString], "this is a string"))
+ abort ();
+ return 0;
+}
--- /dev/null
+# String tests that should be run at all optimization levels.
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+load_lib obj-c++-dg.exp
+
+dg-init
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
+
+obj-c++-dg-runtest $tests "-fgnu-runtime"
+
+# Darwin targets can also run code with the NeXT runtime.
+if [istarget "*-*-darwin*" ] {
+ obj-c++-dg-runtest $tests "-fnext-runtime"
+}
+
+dg-finish
*/
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
/* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
-#import "../objc-obj-c++-shared/Object1.h"
-#import "../objc-obj-c++-shared/next-mapping.h"
+#include "../objc-obj-c++-shared/Object1.h"
+#include "../objc-obj-c++-shared/next-mapping.h"
#ifndef __NEXT_RUNTIME__
#include <objc/NXConstStr.h>
#endif
*/
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
/* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
#import "../objc-obj-c++-shared/Object1.h"
*/
/* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
/* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
#import "../objc-obj-c++-shared/Object1.h"
--- /dev/null
+/* Test the -Wnonportable-cfstrings option, which should give
+ warnings if non-ASCII characters are embedded in constant
+ CFStrings. This will only work on MacOS X 10.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -Wnonportable-cfstrings" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+
+#ifndef __CONSTANT_CFSTRINGS__
+#error The -fconstant-cfstrings option is not functioning properly
+#endif
+
+void foo(void) {
+ NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+ NSString *s3 = @"Non-ASCII literal - \222"; /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s4 = CFSTR("\222 - Non-ASCII literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s5 = CFSTR("Non-ASCII (\222) literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ NSString *s6 = @"\0Embedded NUL"; /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s7 = CFSTR("Embedded \0NUL"); /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s8 = CFSTR("Embedded NUL\0"); /* { dg-warning "embedded NUL in CFString literal" } */
+}
--- /dev/null
+/* Test if constant CFStrings may be passed back as ObjC strings. */
+/* Author: Ziemowit Laski */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings" } */
+
+#include <objc/Object.h>
+
+@interface Foo: Object {
+ char *cString;
+ unsigned int len;
+}
++ (Foo *)description;
+@end
+
+@interface Bar: Object
++ (Foo *) getString: (int) which;
+@end
+
+@implementation Bar
++ (Foo *) getString: (int) which {
+ return which? [Foo description]: @"Hello";
+}
+@end
/* Test errors for constant strings. */
/* { dg-do compile } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
#ifdef __cplusplus
extern void baz(...);
/* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
-#import "../objc-obj-c++-shared/next-mapping.h"
+#include "../../objc-obj-c++-shared/Object1.h"
+#import "../../objc-obj-c++-shared/next-mapping.h"
@interface Foo: Object {
char *cString;
/* Test the -fconstant-string-class flag error. */
/* { dg-do compile } */
-/* { dg-options "-fconstant-string-class=" } */
+/* { dg-options "-fconstant-string-class=" { target *-*-* } } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=" { target *-*-darwin* } } */
{ dg-error "no class name specified|missing argument" "" { target *-*-* } 0 }
/* Positive test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=MyConstantString" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase {
const char *p;
/* Negative test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */
+/* { dg-options "-fconstant-string-class=MyConstantString" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase {
char p;
--- /dev/null
+# String tests that only need to run at default optimization.
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Load support procs.
+
+load_lib objc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS ""
+}
+
+# Initialize `dg'.
+dg-init
+
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
+
+# Main loop.
+dg-runtest $tests "-fgnu-runtime" $DEFAULT_CFLAGS
+
+# darwin targets can also run code with the NeXT runtime.
+if [istarget "*-*-darwin*" ] {
+ dg-runtest $tests "-fnext-runtime" $DEFAULT_CFLAGS
+}
+
+# All done.
+dg-finish
--- /dev/null
+/* Test the -fconstant-cfstrings option for constructing
+ compile-time immutable CFStrings, and their interoperation
+ with both Cocoa and CoreFoundation. This will only work
+ on MacOS X 10.1.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -framework Cocoa" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+#include <stdlib.h>
+
+void printOut(NSString *str) {
+ NSLog(@"The value of str is: %@", str);
+}
+
+CFStringRef s0a = CFSTR("Compile-time string literal");
+CFStringRef s0b = CFSTR("Compile-time string literal");
+
+void checkNSRange(NSRange r) {
+ if (r.location != 6 || r.length != 5) {
+ printOut(@"Range check failed");
+ abort();
+ }
+}
+
+void checkCFRange(CFRange r) {
+ if (r.location != 6 || r.length != 5) {
+ printOut(@"Range check failed");
+ abort();
+ }
+}
+
+int main(void) {
+ const NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+
+ checkNSRange([@"Hello World" rangeOfString:@"World"]);
+ checkNSRange([(id)CFSTR("Hello World") rangeOfString:@"World"]);
+ checkNSRange([@"Hello World" rangeOfString:(id)CFSTR("World")]);
+ checkNSRange([(id)CFSTR("Hello World") rangeOfString:(id)CFSTR("World")]);
+
+ checkCFRange(CFStringFind((CFStringRef)@"Hello World", (CFStringRef)@"World", 0));
+ checkCFRange(CFStringFind(CFSTR("Hello World"), (CFStringRef)@"World", 0));
+ checkCFRange(CFStringFind((CFStringRef)@"Hello World", CFSTR("World"), 0));
+ checkCFRange(CFStringFind(CFSTR("Hello World"), CFSTR("World"), 0));
+
+ /* Check for string uniquing. */
+ if (s0a != s0b || s0a != s2 || s1 != (id)s2) {
+ NSLog(@"String uniquing failed");
+ abort ();
+ }
+
+ return 0;
+}
--- /dev/null
+/* Test for assigning compile-time constant-string objects to static variables. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com> */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings -framework Foundation" } */
+
+#include <stdlib.h>
+
+typedef const struct __CFString * CFStringRef;
+static CFStringRef appKey = (CFStringRef) @"com.apple.soundpref";
+
+static int CFPreferencesSynchronize (CFStringRef ref) {
+ return ref == appKey;
+}
+
+static void PrefsSynchronize()
+{
+ if(!CFPreferencesSynchronize(appKey))
+ abort();
+}
+
+int main(void) {
+ PrefsSynchronize();
+ return 0;
+}
--- /dev/null
+/* Test if constant CFStrings get placed in the correct section and that the
+ layout of the object is correct for both m32 and m64. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com> */
+
+/* So far, CFString is darwin-only. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mconstant-cfstrings" } */
+
+typedef const struct __CFString * CFStringRef;
+static CFStringRef appKey = (CFStringRef) @"com.apple.soundpref";
+
+void *foo (void)
+{
+ void *a = (void *)appKey;
+ return a;
+}
+
+/* { dg-final { scan-assembler ".section __DATA, __cfstring" } } */
+/* { dg-final { scan-assembler ".long\t___CFConstantStringClassReference\n\t.long\t1992\n\t.long\t.*\n\t.long\t19\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t19\n" { target { *-*-darwin* && { lp64 } } } } } */
/* { dg-do compile { target { *-*-darwin* } } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface NSString: Object
@end
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-fconstant-string-class=XStr" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=XStr" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface XString: Object {
@protected
/* Test the -fconstant-string-class=Foo option under the NeXT runtime. */
/* Developed by Markus Hitter <mah@jump-ing.de>. */
/* { dg-do run } */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
-#import "../objc-obj-c++-shared/Object1.h"
-#import "../objc-obj-c++-shared/next-mapping.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/next-mapping.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
printf([@"This is a working constant string object\n" customString]);
return 0;
}
-
-#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Ensure that the preprocessor handles ObjC string constants gracefully. */
/* Author: Ziemowit Laski <zlaski@apple.com> */
-/* { dg-options "-fconstant-string-class=MyString " } */
/* { dg-do run } */
+/* { dg-options "-fconstant-string-class=MyString " } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyString " { target *-*-darwin* } } */
extern void abort(void);
/* Test to make sure that the const objc strings are the same across scopes. */
/* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
-/* { dg-options "-fconstant-string-class=Foo " } */
/* { dg-do run } */
+/* { dg-options "-fconstant-string-class=Foo " } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
- (char *)customString;
@end
-#ifndef NEXT_OBJC_USE_NEW_INTERFACE
-struct objc_class _FooClassReference;
-#else
+#ifdef NEXT_OBJC_USE_NEW_INTERFACE
Class _FooClassReference;
+#else
+struct objc_class _FooClassReference;
#endif
@implementation Foo : Object
}
return 0;
}
-
-#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Test for assigning compile-time constant-string objects to static variables. */
/* Contributed by Ziemowit Laski <zlaski@apple.com> */
-/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run } */
+/* { dg-options "-fconstant-string-class=Foo" } */
+/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
#include <stdlib.h>
@interface Foo: Object {
}
@end
-#ifndef NEXT_OBJC_USE_NEW_INTERFACE
-struct objc_class _FooClassReference;
-#else
+#ifdef NEXT_OBJC_USE_NEW_INTERFACE
Class _FooClassReference;
+#else
+struct objc_class _FooClassReference;
#endif
@implementation Foo : Object
PrefsSynchronize();
return 0;
}
-
-#include "../objc-obj-c++-shared/Object1-implementation.h"
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
-#include "../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/Object1.h"
@interface NSConstantString: Object {
char *cString;
--- /dev/null
+/* Based on a test case contributed by Nicola Pero. */
+
+/* { dg-do run } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
+
+#include "../../../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/next-mapping.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef __NEXT_RUNTIME__
+#include <objc/NXConstStr.h>
+#endif
+
+int main(int argc, void **args)
+{
+ if (strcmp ([@"this is a string" cString], "this is a string"))
+ abort ();
+ return 0;
+}
--- /dev/null
+/* Based on a test case contributed by Nicola Pero. */
+
+/* { dg-do run } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
+
+#include "../../../objc-obj-c++-shared/Object1.h"
+#include "../../../objc-obj-c++-shared/next-mapping.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef __NEXT_RUNTIME__
+#include <objc/NXConstStr.h>
+#endif
+
+int main(int argc, void **args)
+{
+ if (strcmp ([@"this " @"is " @"a " @"string" cString],
+ "this " "is " "a " "string"))
+ abort ();
+ return 0;
+}
--- /dev/null
+/* Based on a test case contributed by Nicola Pero. */
+
+/* { dg-do run } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
+
+#include "../../../objc-obj-c++-shared/Object1.h"
+#import "../../../objc-obj-c++-shared/next-mapping.h"
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef __NEXT_RUNTIME__
+#include <objc/NXConstStr.h>
+#endif
+
+#define STRING "this is a string"
+
+int main (int argc, void **args)
+{
+ if (strcmp ([@STRING cString], STRING))
+ abort ();
+ return 0;
+}
--- /dev/null
+/* Based on a test case contributed by Nicola Pero. */
+
+/* { dg-do run } */
+/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../../../objc-obj-c++-shared/Object1.m" } */
+
+#include "../../../objc-obj-c++-shared/Object1.h"
+#import "../../../objc-obj-c++-shared/next-mapping.h"
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef __NEXT_RUNTIME__
+#include <objc/NXConstStr.h>
+#endif
+
+int main(int argc, void **args)
+{
+ if ([@"this is a string" length] != strlen ("this is a string"))
+ abort ();
+ return 0;
+}
--- /dev/null
+# String tests that should be run at all optimization levels.
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+load_lib objc-dg.exp
+load_lib target-supports-dg.exp
+
+dg-init
+
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
+
+objc-dg-runtest $tests "-fgnu-runtime"
+
+# Darwin targets also test with the NeXT runtime.
+if [istarget "*-*-darwin*" ] {
+ objc-dg-runtest $tests "-fnext-runtime"
+}
+
+dg-finish
+++ /dev/null
-/* Based on a test case contributed by Nicola Pero. */
-
-#import "../../objc-obj-c++-shared/next-mapping.h"
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef __NEXT_RUNTIME__
-#include <objc/NXConstStr.h>
-#endif
-
-int main(int argc, void **args)
-{
- if (strcmp ([@"this is a string" cString], "this is a string"))
- abort ();
- return 0;
-}
+++ /dev/null
-/* Based on a test case contributed by Nicola Pero. */
-
-#import "../../objc-obj-c++-shared/next-mapping.h"
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef __NEXT_RUNTIME__
-#include <objc/NXConstStr.h>
-#endif
-
-int main(int argc, void **args)
-{
- if (strcmp ([@"this " @"is " @"a " @"string" cString],
- "this " "is " "a " "string"))
- abort ();
- return 0;
-}
+++ /dev/null
-/* Based on a test case contributed by Nicola Pero. */
-
-#import "../../objc-obj-c++-shared/next-mapping.h"
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef __NEXT_RUNTIME__
-#include <objc/NXConstStr.h>
-#endif
-
-#define STRING "this is a string"
-
-int main (int argc, void **args)
-{
- if (strcmp ([@STRING cString], STRING))
- abort ();
- return 0;
-}
+++ /dev/null
-/* Based on a test case contributed by Nicola Pero. */
-
-#import "../../objc-obj-c++-shared/next-mapping.h"
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef __NEXT_RUNTIME__
-#include <objc/NXConstStr.h>
-#endif
-
-int main(int argc, void **args)
-{
- if ([@"this is a string" length] != strlen ("this is a string"))
- abort ();
- return 0;
-}