aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/objc.dg/special
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/objc.dg/special
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/objc.dg/special')
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.h20
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.m39
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1a.m21
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.h19
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.m105
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2a.m46
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.h17
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.m87
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3a.m65
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/special.exp145
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.h25
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.m70
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m29
13 files changed, 688 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.h b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.h
new file mode 100644
index 000000000..7810487df
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.h
@@ -0,0 +1,20 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+/* Test that +load works when a category is defined in a different
+ module than the main class. */
+
+/* This function should be called any time +load is invoked, so we can
+ keep the count. */
+extern int increase_load_count (void);
+
+@interface TestClass1
+{
+ id isa;
+}
+@end
+
+@interface TestClass2
+{
+ id isa;
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.m
new file mode 100644
index 000000000..cb221436f
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1.m
@@ -0,0 +1,39 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-1.h"
+
+@implementation TestClass1
++ initialize { return self; }
++ load
+{
+ increase_load_count ();
+}
+@end
+
+@implementation TestClass2 (Category)
++ load
+{
+ increase_load_count ();
+}
+@end
+
+
+static int load_count = 0;
+
+int increase_load_count (void)
+{
+ load_count++;
+}
+
+int main (void)
+{
+ if (load_count != 4)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1a.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1a.m
new file mode 100644
index 000000000..cdcb7d829
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-1a.m
@@ -0,0 +1,21 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-1.h"
+
+@implementation TestClass2
++ initialize { return self; }
++ load
+{
+ increase_load_count ();
+}
+@end
+
+@implementation TestClass1 (Category)
++ load
+{
+ increase_load_count ();
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.h b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.h
new file mode 100644
index 000000000..ae7e84278
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.h
@@ -0,0 +1,19 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+/* Test the order of calling +load between classes and categories. */
+
+void complete_load_step (int load_step);
+void check_that_load_step_was_completed (int load_step);
+void check_that_load_step_was_not_completed (int load_step);
+
+@interface TestClass1
+{
+ id isa;
+}
+@end
+
+@interface TestClass2 : TestClass1
+@end
+
+@interface TestClass3 : TestClass2
+@end
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.m
new file mode 100644
index 000000000..7dc745952
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2.m
@@ -0,0 +1,105 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-2.h"
+
+/* This test tests that +load is called in the correct order for
+ classes and categories. +load needs to be called in superclasses
+ before subclasses, and in the main class before categories. */
+
+/* Compile the classes in random order to prevent the runtime from
+ sending +load in the correct order just because the classes happen
+ to have been compiled in that order. */
+@implementation TestClass2
++ load
+{
+ printf ("[TestClass2 +load]\n");
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_not_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (4);
+
+ complete_load_step (1);
+}
+@end
+
+@implementation TestClass3
++ load
+{
+ printf ("[TestClass3 +load]\n");
+
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (5);
+
+ complete_load_step (2);
+}
+@end
+
+@implementation TestClass1
++ initialize { return self; }
++ load
+{
+ printf ("[TestClass1 +load]\n");
+
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_not_completed (0);
+ check_that_load_step_was_not_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (3);
+
+ complete_load_step (0);
+}
+@end
+
+
+static BOOL load_step_completed[6] = { NO, NO, NO, NO, NO, NO };
+
+void complete_load_step (int load_step)
+{
+ load_step_completed[load_step] = YES;
+}
+
+void check_that_load_step_was_completed (int load_step)
+{
+ if (load_step_completed[load_step] == NO)
+ {
+ printf ("Load step %d was not completed but should have been\n", load_step);
+ abort ();
+ }
+}
+
+void check_that_load_step_was_not_completed (int load_step)
+{
+ if (load_step_completed[load_step] == YES)
+ {
+ printf ("Load step %d was completed but shouldn't have been\n", load_step);
+ abort ();
+ }
+}
+
+int main (void)
+{
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_completed (1);
+ check_that_load_step_was_completed (2);
+ check_that_load_step_was_completed (3);
+ check_that_load_step_was_completed (4);
+ check_that_load_step_was_completed (5);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2a.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2a.m
new file mode 100644
index 000000000..6b81240db
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-2a.m
@@ -0,0 +1,46 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-2.h"
+
+/* Compile the categories in random order to prevent the runtime from
+ sending +load in the correct order just because the classes happen
+ to have been compiled in that order. */
+@implementation TestClass2 (Category)
++ load
+{
+ printf ("[TestClass2(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (1);
+
+ complete_load_step (4);
+}
+@end
+
+@implementation TestClass3 (Category)
++ load
+{
+ printf ("[TestClass3(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (2);
+
+ complete_load_step (5);
+}
+@end
+
+@implementation TestClass1 (Category)
++ load
+{
+ printf ("[TestClass1(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (0);
+
+ complete_load_step (3);
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.h b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.h
new file mode 100644
index 000000000..9d6d8acc9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.h
@@ -0,0 +1,17 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+void complete_load_step (int load_step);
+void check_that_load_step_was_completed (int load_step);
+void check_that_load_step_was_not_completed (int load_step);
+
+@interface TestClass1
+{
+ id isa;
+}
+@end
+
+@interface TestClass2 : TestClass1
+@end
+
+@interface TestClass3 : TestClass2
+@end
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.m
new file mode 100644
index 000000000..b89d8f152
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3.m
@@ -0,0 +1,87 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+/* This test is identical to load-category-2, but the classes and
+ categories are created in inverted order in the modules, to test
+ that you can load classes first, or categories first, and it all
+ still works in both cases. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-3.h"
+
+@implementation TestClass2 (Category)
++ load
+{
+ printf ("[TestClass2(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (1);
+
+ complete_load_step (4);
+}
+@end
+
+@implementation TestClass3 (Category)
++ load
+{
+ printf ("[TestClass3(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (2);
+
+ complete_load_step (5);
+}
+@end
+
+@implementation TestClass1 (Category)
++ load
+{
+ printf ("[TestClass1(Category) +load]\n");
+
+ /* Check that the corresponding class's +load was done. */
+ check_that_load_step_was_completed (0);
+
+ complete_load_step (3);
+}
+@end
+
+static BOOL load_step_completed[6] = { NO, NO, NO, NO, NO, NO };
+
+void complete_load_step (int load_step)
+{
+ load_step_completed[load_step] = YES;
+}
+
+void check_that_load_step_was_completed (int load_step)
+{
+ if (load_step_completed[load_step] == NO)
+ {
+ printf ("Load step %d was not completed but should have been\n", load_step);
+ abort ();
+ }
+}
+
+void check_that_load_step_was_not_completed (int load_step)
+{
+ if (load_step_completed[load_step] == YES)
+ {
+ printf ("Load step %d was completed but shouldn't have been\n", load_step);
+ abort ();
+ }
+}
+
+int main (void)
+{
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_completed (1);
+ check_that_load_step_was_completed (2);
+ check_that_load_step_was_completed (3);
+ check_that_load_step_was_completed (4);
+ check_that_load_step_was_completed (5);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3a.m b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3a.m
new file mode 100644
index 000000000..5ce5fac65
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/load-category-3a.m
@@ -0,0 +1,65 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+/* This test is identical to load-category-2, but the classes and
+ categories are created in inverted order in the modules, to test
+ that you can load classes first, or categories first, and it all
+ still works. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <objc/objc.h>
+
+#include "load-category-3.h"
+
+@implementation TestClass2
++ load
+{
+ printf ("[TestClass2 +load]\n");
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_not_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (4);
+
+ complete_load_step (1);
+}
+@end
+
+@implementation TestClass3
++ load
+{
+ printf ("[TestClass3 +load]\n");
+
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_completed (0);
+ check_that_load_step_was_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (5);
+
+ complete_load_step (2);
+}
+@end
+
+@implementation TestClass1
++ initialize { return self; }
++ load
+{
+ printf ("[TestClass1 +load]\n");
+
+ /* Check superclasses/subclasses +load order. */
+ check_that_load_step_was_not_completed (0);
+ check_that_load_step_was_not_completed (1);
+ check_that_load_step_was_not_completed (2);
+
+ /* Check that the corresponding category's +load was not done. */
+ check_that_load_step_was_not_completed (3);
+
+ complete_load_step (0);
+}
+@end
+
+
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/special.exp b/gcc-4.9/gcc/testsuite/objc.dg/special/special.exp
new file mode 100644
index 000000000..fb9bd0bec
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/special.exp
@@ -0,0 +1,145 @@
+# GCC Objective-C testsuite that uses the `dg.exp' driver.
+# Copyright (C) 1997-2014 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 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
+
+# TODO: All these testcases compile and link two Objective-C modules.
+# Remove code duplication and factor the common code out.
+
+#
+# unclaimed-category-1 test
+#
+# This test is special because we must compile two different modules,
+# unclaimed-category-1a.m and unclaimed-category-1.m, then link
+# together, then run the resulting executable.
+# for all systems we point to the libobjc includes and use the -fgnu-runtime
+set add_flags "additional_flags=-I${srcdir}/../../libobjc"
+lappend add_flags "additional_flags=-fgnu-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "unclaimed-category-1a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-I${srcdir}/../../libobjc -fgnu-runtime"
+ file delete unclaimed-category-1a.o
+}
+
+if [istarget "*-*-darwin*" ] {
+set add_flags ""
+lappend add_flags "additional_flags=-fnext-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "unclaimed-category-1a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-fnext-runtime"
+ file delete unclaimed-category-1a.o
+}
+}
+
+#
+# load-category-1 test
+#
+# This test is similar to the one above. We compile load-category-1.m
+# and load-category-1a.m, link them together, and execute the result.
+set add_flags "additional_flags=-I${srcdir}/../../libobjc"
+lappend add_flags "additional_flags=-fgnu-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-1a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-1.m" "load-category-1a.o" "-I${srcdir}/../../libobjc -fgnu-runtime"
+ file delete load-category-1a.o
+}
+
+if [istarget "*-*-darwin*" ] {
+set add_flags ""
+lappend add_flags "additional_flags=-fnext-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-1a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-1.m" "load-category-1a.o" "-fnext-runtime"
+ file delete load-category-1a.o
+}
+}
+
+#
+# load-category-2 test
+#
+# This test is similar to the one above. We compile load-category-2.m
+# and load-category-2a.m, link them together, and execute the result.
+set add_flags "additional_flags=-I${srcdir}/../../libobjc"
+lappend add_flags "additional_flags=-fgnu-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-2a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-2.m" "load-category-2a.o" "-I${srcdir}/../../libobjc -fgnu-runtime"
+ file delete load-category-2a.o
+}
+
+if [istarget "*-*-darwin*" ] {
+set add_flags ""
+lappend add_flags "additional_flags=-fnext-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-2a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-2.m" "load-category-2a.o" "-fnext-runtime"
+ file delete load-category-2a.o
+}
+}
+
+#
+# load-category-3 test
+#
+# This test is similar to the one above. We compile load-category-3.m
+# and load-category-3a.m, link them together, and execute the result.
+set add_flags "additional_flags=-I${srcdir}/../../libobjc"
+lappend add_flags "additional_flags=-fgnu-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-3a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-3.m" "load-category-3a.o" "-I${srcdir}/../../libobjc -fgnu-runtime"
+ file delete load-category-3a.o
+}
+
+if [istarget "*-*-darwin*" ] {
+set add_flags ""
+lappend add_flags "additional_flags=-fnext-runtime"
+set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ]
+if ![string match "" $lines] then {
+ fail "load-category-3a.o"
+} else {
+ dg-runtest "$srcdir/$subdir/load-category-3.m" "load-category-3a.o" "-fnext-runtime"
+ file delete load-category-3a.o
+}
+}
+
+# All done.
+dg-finish
+
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.h b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
new file mode 100644
index 000000000..a32024df5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
@@ -0,0 +1,25 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+@interface TestClass
+{
+ Class isa;
+}
+- (int)D;
+@end
+
+@interface TestClass (A)
+- (int)A;
+@end
+
+@interface TestClass (B)
+- (int)B;
+@end
+
+@interface TestClass (C)
+- (int)C;
+@end
+
+
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.m b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
new file mode 100644
index 000000000..7b434b4db
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
@@ -0,0 +1,70 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+#include <objc/objc.h>
+#include "../../objc-obj-c++-shared/runtime.h"
+
+extern void abort (void);
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+
+/* unclaimed-category-1.m contains only the class definition but not
+ the categories. unclaimed-category-1a.m contains only the
+ categories of the class, but not the class itself. We want to
+ check that the runtime can load the class from one module (file)
+ and the categories from another module (file). */
+
+#include "unclaimed-category-1.h"
+
+@implementation TestClass
+- (int)D
+{
+ return 4;
+}
++ initialize { return self; }
+@end
+
+
+int main (void)
+{
+ TestClass *test;
+ Class testClass;
+
+ testClass = objc_getClass ("TestClass");
+ if (testClass == Nil)
+ {
+ abort ();
+ }
+
+ test = (TestClass *)(class_createInstance (testClass, 0));
+ if (test == nil)
+ {
+ abort ();
+ }
+
+ if ([test A] != 1)
+ {
+ abort ();
+ }
+
+ if ([test B] != 2)
+ {
+ abort ();
+ }
+
+ if ([test C] != 3)
+ {
+ abort ();
+ }
+
+
+ if ([test D] != 4)
+ {
+ abort ();
+ }
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m
new file mode 100644
index 000000000..4fb2d4619
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/special/unclaimed-category-1a.m
@@ -0,0 +1,29 @@
+/* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+
+/* Test loading unclaimed categories - categories of a class defined
+ separately from the class itself. */
+
+#include "unclaimed-category-1.h"
+
+@implementation TestClass (A)
+- (int)A
+{
+ return 1;
+}
+@end
+
+@implementation TestClass (B)
+- (int)B
+{
+ return 2;
+}
+@end
+
+@implementation TestClass (C)
+- (int)C
+{
+ return 3;
+}
+@end
+
+