Commit 0937fb69 by Iain Sandoe

CFStrings for Darwin

gcc/testsuite:
	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.

From-SVN: r165821
parent 26705988
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> 2010-10-22 Marcus Shawcroft <marcus.shawcroft@arm.com>
* gcc.target/arm/synchronize.c: Permit dmb or mcr in assembler scan. * gcc.target/arm/synchronize.c: Permit dmb or mcr in assembler scan.
......
...@@ -30,5 +30,44 @@ proc obj-c++-dg-prune { system text } { ...@@ -30,5 +30,44 @@ proc obj-c++-dg-prune { system text } {
# Modified dg-runtest that can cycle through a list of optimization options # Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does. # as c-torture does.
proc obj-c++-dg-runtest { testcases default-extra-flags } { 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
...@@ -31,5 +31,44 @@ proc objc-dg-prune { system text } { ...@@ -31,5 +31,44 @@ proc objc-dg-prune { system text } {
# Modified dg-runtest that can cycle through a list of optimization options # Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does. # as c-torture does.
proc objc-dg-runtest { testcases default-extra-flags } { 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
}
} }
/* 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" } */
}
/* 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. */ /* Test errors for constant strings. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
#ifdef __cplusplus #ifdef __cplusplus
extern void baz(...); extern void baz(...);
......
/* Test if ObjC types play nice in conditional expressions. */ /* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */ /* Author: Ziemowit Laski */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */ /* { 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" #include "../../objc-obj-c++-shared/Object1.h"
#import "../objc-obj-c++-shared/next-mapping.h"
@interface Foo: Object { @interface Foo: Object {
char *cString; char *cString;
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
@end @end
#ifdef NEXT_OBJC_USE_NEW_INTERFACE #ifdef NEXT_OBJC_USE_NEW_INTERFACE
struct fudge_objc_class _FooClassReference; Class _FooClassReference;
#else #else
struct objc_class _FooClassReference; struct objc_class _FooClassReference;
#endif #endif
......
/* Test the -fconstant-string-class flag error. */ /* Test the -fconstant-string-class flag error. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-fconstant-string-class=" } */ /* { 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 } { dg-error "no class name specified|missing argument" "" { target *-*-* } 0 }
......
/* Positive test case for constant string layout. */ /* Positive test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */ /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase { @interface MyBase {
const char *p; const char *p;
......
/* Negative test case for constant string layout. */ /* Negative test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */ /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase { @interface MyBase {
char p; char p;
......
# 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
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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/Object1.h"
#include "../objc-obj-c++-shared/next-mapping.h" #include "../objc-obj-c++-shared/next-mapping.h"
#include <stdarg.h> #include <stdarg.h>
...@@ -76,4 +79,3 @@ int main(void) { ...@@ -76,4 +79,3 @@ int main(void) {
CHECK_IF(abc(a1, a2) * t.k == 35); CHECK_IF(abc(a1, a2) * t.k == 35);
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
/* 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;
}
/* 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;
}
/* 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 } } } } } */
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { 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 @interface NSString: Object
@end @end
......
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-fconstant-string-class=XStr" } */ /* { 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 { @interface XString: Object {
@protected @protected
...@@ -20,10 +21,10 @@ ...@@ -20,10 +21,10 @@
} }
@end @end
#ifndef NEXT_OBJC_USE_NEW_INTERFACE #ifdef NEXT_OBJC_USE_NEW_INTERFACE
extern struct objc_class _XStrClassReference;
#else
extern Class _XStrClassReference; extern Class _XStrClassReference;
#else
extern struct objc_class _XStrClassReference;
#endif #endif
const XStr *appKey = @"MyApp"; const XStr *appKey = @"MyApp";
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
runtime. */ runtime. */
/* Developed by Markus Hitter <mah@jump-ing.de>. */ /* Developed by Markus Hitter <mah@jump-ing.de>. */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run { target *-*-darwin* } } */ /* { dg-do run { target *-*-darwin* } } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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/Object1.h"
#import "../objc-obj-c++-shared/next-mapping.h" #import "../../../objc-obj-c++-shared/next-mapping.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
...@@ -55,4 +57,4 @@ int main () { ...@@ -55,4 +57,4 @@ int main () {
printf([@"This is a working constant string object\n" customString]); printf([@"This is a working constant string object\n" customString]);
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Ensure that the preprocessor handles ObjC string constants gracefully. */ /* Ensure that the preprocessor handles ObjC string constants gracefully. */
/* Author: Ziemowit Laski <zlaski@apple.com> */ /* Author: Ziemowit Laski <zlaski@apple.com> */
/* { dg-options "-fconstant-string-class=MyString" } */
/* { dg-do run { target *-*-darwin* } } */ /* { 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> #include <stdlib.h>
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
scopes. */ scopes. */
/* Developed by Andrew Pinski <pinskia@physics.uc.edu> */ /* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run } */ /* { 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/Object1.h"
#include "../objc-obj-c++-shared/next-mapping.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
@end @end
#ifdef NEXT_OBJC_USE_NEW_INTERFACE #ifdef NEXT_OBJC_USE_NEW_INTERFACE
struct fudge_objc_class _FooClassReference; Class _FooClassReference;
#else #else
struct objc_class _FooClassReference; struct objc_class _FooClassReference;
#endif #endif
...@@ -44,4 +44,3 @@ int main () { ...@@ -44,4 +44,3 @@ int main () {
} }
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Test for assigning compile-time constant-string objects to static variables. */ /* Test for assigning compile-time constant-string objects to static variables. */
/* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* Contributed by Ziemowit Laski <zlaski@apple.com> */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run { target *-*-darwin* } } */ /* { 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> #include <stdlib.h>
@interface Foo: Object { @interface Foo: Object {
...@@ -40,5 +42,3 @@ int main () { ...@@ -40,5 +42,3 @@ int main () {
PrefsSynchronize(); PrefsSynchronize();
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { 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 { @interface NSConstantString: Object {
char *cString; char *cString;
......
/* 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;
}
# 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
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
*/ */
/* { dg-do run } */ /* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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" } */ /* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
#import "../objc-obj-c++-shared/Object1.h" #include "../objc-obj-c++-shared/Object1.h"
#import "../objc-obj-c++-shared/next-mapping.h" #include "../objc-obj-c++-shared/next-mapping.h"
#ifndef __NEXT_RUNTIME__ #ifndef __NEXT_RUNTIME__
#include <objc/NXConstStr.h> #include <objc/NXConstStr.h>
#endif #endif
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
/* { dg-do run } */ /* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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" } */ /* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
#import "../objc-obj-c++-shared/Object1.h" #import "../objc-obj-c++-shared/Object1.h"
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
/* { dg-do run } */ /* { dg-do run } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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" } */ /* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
#import "../objc-obj-c++-shared/Object1.h" #import "../objc-obj-c++-shared/Object1.h"
......
/* 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" } */
}
/* 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. */ /* Test errors for constant strings. */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
#ifdef __cplusplus #ifdef __cplusplus
extern void baz(...); extern void baz(...);
......
/* Test if ObjC types play nice in conditional expressions. */ /* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */ /* Author: Ziemowit Laski */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */ /* { 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" #include "../../objc-obj-c++-shared/Object1.h"
#import "../objc-obj-c++-shared/next-mapping.h" #import "../../objc-obj-c++-shared/next-mapping.h"
@interface Foo: Object { @interface Foo: Object {
char *cString; char *cString;
......
/* Test the -fconstant-string-class flag error. */ /* Test the -fconstant-string-class flag error. */
/* { dg-do compile } */ /* { 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 } { dg-error "no class name specified|missing argument" "" { target *-*-* } 0 }
......
/* Positive test case for constant string layout. */ /* Positive test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */ /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase { @interface MyBase {
const char *p; const char *p;
......
/* Negative test case for constant string layout. */ /* Negative test case for constant string layout. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */ /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-fconstant-string-class=MyConstantString" } */
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyConstantString" { target *-*-darwin* } } */
@interface MyBase { @interface MyBase {
char p; char p;
......
# 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
/* 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;
}
/* 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;
}
/* 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 } } } } } */
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
/* { dg-do compile { target { *-*-darwin* } } } */ /* { dg-do compile { target { *-*-darwin* } } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { 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 @interface NSString: Object
@end @end
......
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
/* { dg-do compile { target *-*-darwin* } } */ /* { dg-do compile { target *-*-darwin* } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-fconstant-string-class=XStr" } */ /* { 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 { @interface XString: Object {
@protected @protected
......
/* Test the -fconstant-string-class=Foo option under the NeXT runtime. */ /* Test the -fconstant-string-class=Foo option under the NeXT runtime. */
/* Developed by Markus Hitter <mah@jump-ing.de>. */ /* Developed by Markus Hitter <mah@jump-ing.de>. */
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { 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" #include "../../../objc-obj-c++-shared/Object1.h"
#import "../objc-obj-c++-shared/next-mapping.h" #include "../../../objc-obj-c++-shared/next-mapping.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -49,5 +51,3 @@ int main () { ...@@ -49,5 +51,3 @@ int main () {
printf([@"This is a working constant string object\n" customString]); printf([@"This is a working constant string object\n" customString]);
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Ensure that the preprocessor handles ObjC string constants gracefully. */ /* Ensure that the preprocessor handles ObjC string constants gracefully. */
/* Author: Ziemowit Laski <zlaski@apple.com> */ /* Author: Ziemowit Laski <zlaski@apple.com> */
/* { dg-options "-fconstant-string-class=MyString " } */
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-fconstant-string-class=MyString " } */
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyString " { target *-*-darwin* } } */
extern void abort(void); extern void abort(void);
......
/* Test to make sure that the const objc strings are the same across scopes. */ /* Test to make sure that the const objc strings are the same across scopes. */
/* Developed by Andrew Pinski <pinskia@physics.uc.edu> */ /* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
/* { dg-options "-fconstant-string-class=Foo " } */
/* { dg-do run } */ /* { 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -15,10 +17,10 @@ ...@@ -15,10 +17,10 @@
- (char *)customString; - (char *)customString;
@end @end
#ifndef NEXT_OBJC_USE_NEW_INTERFACE #ifdef NEXT_OBJC_USE_NEW_INTERFACE
struct objc_class _FooClassReference;
#else
Class _FooClassReference; Class _FooClassReference;
#else
struct objc_class _FooClassReference;
#endif #endif
@implementation Foo : Object @implementation Foo : Object
...@@ -38,5 +40,3 @@ int main () { ...@@ -38,5 +40,3 @@ int main () {
} }
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
/* Test for assigning compile-time constant-string objects to static variables. */ /* Test for assigning compile-time constant-string objects to static variables. */
/* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* Contributed by Ziemowit Laski <zlaski@apple.com> */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do run } */ /* { 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> #include <stdlib.h>
@interface Foo: Object { @interface Foo: Object {
...@@ -12,10 +14,10 @@ ...@@ -12,10 +14,10 @@
} }
@end @end
#ifndef NEXT_OBJC_USE_NEW_INTERFACE #ifdef NEXT_OBJC_USE_NEW_INTERFACE
struct objc_class _FooClassReference;
#else
Class _FooClassReference; Class _FooClassReference;
#else
struct objc_class _FooClassReference;
#endif #endif
@implementation Foo : Object @implementation Foo : Object
...@@ -39,5 +41,3 @@ int main () { ...@@ -39,5 +41,3 @@ int main () {
PrefsSynchronize(); PrefsSynchronize();
return 0; return 0;
} }
#include "../objc-obj-c++-shared/Object1-implementation.h"
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { 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 { @interface NSConstantString: Object {
char *cString; char *cString;
......
/* Based on a test case contributed by Nicola Pero. */ /* Based on a test case contributed by Nicola Pero. */
#import "../../objc-obj-c++-shared/next-mapping.h" /* { 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 <string.h>
#include <stdlib.h> #include <stdlib.h>
......
/* Based on a test case contributed by Nicola Pero. */ /* Based on a test case contributed by Nicola Pero. */
#import "../../objc-obj-c++-shared/next-mapping.h" /* { 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 <string.h>
#include <stdlib.h> #include <stdlib.h>
......
/* Based on a test case contributed by Nicola Pero. */ /* Based on a test case contributed by Nicola Pero. */
#import "../../objc-obj-c++-shared/next-mapping.h" /* { 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 <string.h>
#include <stdlib.h> #include <stdlib.h>
......
/* Based on a test case contributed by Nicola Pero. */ /* Based on a test case contributed by Nicola Pero. */
#import "../../objc-obj-c++-shared/next-mapping.h" /* { 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 <string.h>
#include <stdlib.h> #include <stdlib.h>
......
# 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment