aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/objc.dg')
-rw-r--r--gcc/testsuite/objc.dg/call-super-1.m3
-rw-r--r--gcc/testsuite/objc.dg/category-1.m12
-rw-r--r--gcc/testsuite/objc.dg/const-cfstring-1.m57
-rw-r--r--gcc/testsuite/objc.dg/const-cfstring-2.m26
-rw-r--r--gcc/testsuite/objc.dg/const-str-3.m8
-rw-r--r--gcc/testsuite/objc.dg/dg.exp3
-rw-r--r--gcc/testsuite/objc.dg/encode-1.m13
-rw-r--r--gcc/testsuite/objc.dg/nested-func-1.m1
-rw-r--r--gcc/testsuite/objc.dg/objc.c6
9 files changed, 105 insertions, 24 deletions
diff --git a/gcc/testsuite/objc.dg/call-super-1.m b/gcc/testsuite/objc.dg/call-super-1.m
index 19e0d4900dd..b33af776f49 100644
--- a/gcc/testsuite/objc.dg/call-super-1.m
+++ b/gcc/testsuite/objc.dg/call-super-1.m
@@ -1,7 +1,8 @@
+/* APPLE LOCAL file msg send super */
/* Check if objc_super stack variables are created correctly (and
not clobbered by other values). */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-std=c99 -lobjc" } */
+/* { dg-options "-std=c99" } */
/* { dg-do run } */
#include <objc/objc.h>
diff --git a/gcc/testsuite/objc.dg/category-1.m b/gcc/testsuite/objc.dg/category-1.m
index 1d29e374aea..251b125a617 100644
--- a/gcc/testsuite/objc.dg/category-1.m
+++ b/gcc/testsuite/objc.dg/category-1.m
@@ -1,16 +1,10 @@
+/* APPLE LOCAL file objc test suite */
/* Test class methods inside categories. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-options "-lobjc" } */
/* { dg-do run } */
#include <objc/Object.h>
-
-#ifdef __NEXT_RUNTIME__
-#define SUPERCLASS superclass
-#else
-#define SUPERCLASS superClass
-#endif
-
extern int strcmp(const char *s1, const char *s2);
extern void abort(void);
#define CHECK_IF(expr) if(!(expr)) abort()
@@ -20,7 +14,7 @@ extern void abort(void);
@end
@implementation MyObject
-+ (Class)whatever1 { return [super SUPERCLASS]; }
++ (Class)whatever1 { return [super superclass]; }
@end
@interface MyObject (ThisWontCompile)
@@ -28,7 +22,7 @@ extern void abort(void);
@end
@implementation MyObject (ThisWontCompile)
-+(Class)whatever2 { return [super SUPERCLASS]; }
++(Class)whatever2 { return [super superclass]; }
@end
int main (int argc, const char * argv[])
diff --git a/gcc/testsuite/objc.dg/const-cfstring-1.m b/gcc/testsuite/objc.dg/const-cfstring-1.m
new file mode 100644
index 00000000000..24242db02ea
--- /dev/null
+++ b/gcc/testsuite/objc.dg/const-cfstring-1.m
@@ -0,0 +1,57 @@
+/* APPLE LOCAL file constant cfstrings */
+/* 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>. */
+
+/* { dg-do run { target powerpc-apple-darwin* } } */
+/* { dg-options "-fconstant-cfstrings -framework Cocoa" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+
+#ifdef __CONSTANT_CFSTRINGS__
+#undef CFSTR
+#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
+#endif
+
+void printOut(NSString *str) {
+ NSLog(@"The value of str is: %@", str);
+}
+
+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) {
+ NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+
+ if (s1 != (id)s2) {
+ NSLog(@"String comparison failed");
+ abort ();
+ }
+
+ 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));
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc.dg/const-cfstring-2.m b/gcc/testsuite/objc.dg/const-cfstring-2.m
new file mode 100644
index 00000000000..64113c9ee3a
--- /dev/null
+++ b/gcc/testsuite/objc.dg/const-cfstring-2.m
@@ -0,0 +1,26 @@
+/* APPLE LOCAL file constant cfstrings */
+/* 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>. */
+
+/* { dg-do compile { target *-apple-darwin* } } */
+/* { dg-options "-fconstant-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" } */
+}
diff --git a/gcc/testsuite/objc.dg/const-str-3.m b/gcc/testsuite/objc.dg/const-str-3.m
index edc03ff62c7..9fe508b525c 100644
--- a/gcc/testsuite/objc.dg/const-str-3.m
+++ b/gcc/testsuite/objc.dg/const-str-3.m
@@ -1,9 +1,10 @@
+/* APPLE LOCAL file constant strings */
/* Test the -fconstant-string-class=Foo option under the NeXT
runtime. */
/* Developed by Markus Hitter <mah@jump-ing.de>. */
/* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
-/* { dg-do run { target *-*-darwin* } } */
+/* { dg-do run } */
#include <stdio.h>
#include <objc/objc.h>
@@ -26,11 +27,6 @@ struct objc_class _FooClassReference;
int main () {
Foo *string = @"bla";
- Foo *string2 = @"bla";
-
- if(string != string2)
- abort();
- printf("Strings are being uniqued properly\n");
/* This memcpy has to be done before the first message is sent to a
constant string object. Can't be moved to +initialize since _that_
diff --git a/gcc/testsuite/objc.dg/dg.exp b/gcc/testsuite/objc.dg/dg.exp
index ebf952967c7..7b3eba41d98 100644
--- a/gcc/testsuite/objc.dg/dg.exp
+++ b/gcc/testsuite/objc.dg/dg.exp
@@ -28,7 +28,8 @@ if ![info exists DEFAULT_CFLAGS] then {
dg-init
# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[m\]]] \
+# APPLE LOCAL -ObjC
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[mc\]]] \
"" $DEFAULT_CFLAGS
# All done.
diff --git a/gcc/testsuite/objc.dg/encode-1.m b/gcc/testsuite/objc.dg/encode-1.m
index 868c3254753..126e5d010f4 100644
--- a/gcc/testsuite/objc.dg/encode-1.m
+++ b/gcc/testsuite/objc.dg/encode-1.m
@@ -1,9 +1,9 @@
+/* APPLE LOCAL file bool encoding */
/* Test if the Objective-C @encode machinery distinguishes between
- 'BOOL *' (which should be encoded as a pointer to BOOL) and 'char *' (which
- should be encoded as '*'). This is somewhat tricky wrt the NeXT runtime,
- where we have 'typedef char BOOL'. */
+ 'BOOL *' (which should be encoded as '^c') and 'char *' (which
+ should be encoded as '*'). */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
-/* { dg-options "-fnext-runtime -lobjc" } */
+/* { dg-options "-lobjc" } */
/* { dg-do run } */
#include <string.h>
@@ -12,10 +12,9 @@
int main(void) {
const char *BOOL_ptr = @encode(BOOL *);
- const char *BOOL_ = @encode(BOOL);
const char *char_ptr = @encode(char *);
-
- if(*BOOL_ptr != '^' || strcmp(BOOL_ptr + 1, BOOL_))
+
+ if(strcmp(BOOL_ptr, "^c"))
abort();
if(strcmp(char_ptr, "*"))
diff --git a/gcc/testsuite/objc.dg/nested-func-1.m b/gcc/testsuite/objc.dg/nested-func-1.m
index 7a182bd938e..ae45fee8621 100644
--- a/gcc/testsuite/objc.dg/nested-func-1.m
+++ b/gcc/testsuite/objc.dg/nested-func-1.m
@@ -1,3 +1,4 @@
+/* APPLE LOCAL file nested functions */
/* Test basic nested C function functionality within ObjC
methods. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
diff --git a/gcc/testsuite/objc.dg/objc.c b/gcc/testsuite/objc.dg/objc.c
new file mode 100644
index 00000000000..748111c26eb
--- /dev/null
+++ b/gcc/testsuite/objc.dg/objc.c
@@ -0,0 +1,6 @@
+/* APPLE LOCAL file -ObjC */
+
+/* { dg-do compile } */
+/* { dg-options "-ObjC" } */
+
+@class foo;