aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-12-21 15:34:19 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-12-21 15:34:19 +0000
commitc07499dc75cf83ae0b3b20b6c5c6be86142dd25b (patch)
tree61fdf00a963f3916ab9cbcba2bb1052b6c017925 /gcc
parentc8613835dd8af9e8f0e62b8ea0e76f9aadf60057 (diff)
downloadgcc-c07499dc75cf83ae0b3b20b6c5c6be86142dd25b.zip
gcc-c07499dc75cf83ae0b3b20b6c5c6be86142dd25b.tar.gz
gcc-c07499dc75cf83ae0b3b20b6c5c6be86142dd25b.tar.bz2
In libobjc/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/16110 * init.c (__objc_send_message_in_list): Renamed to __objc_send_load_using_method_list. Do not take an 'op' argument. Register the 'load' selector if needed. (__objc_send_load): Do not register the 'load' selector. Updated call to __objc_send_message_in_list. (__objc_create_classes_tree): Add the class of any claimed category that was loaded in the module to the list of classes for which we try to execute +load. In gcc/testsuite/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/16110 * objc.dg/special/special.exp: Added new test. * objc.dg/special/load-category-1.m: New. * objc.dg/special/load-category-1a.m: New. * objc.dg/special/load-category-1.h: New. From-SVN: r168122
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/objc.dg/special/load-category-1.h20
-rw-r--r--gcc/testsuite/objc.dg/special/load-category-1.m40
-rw-r--r--gcc/testsuite/objc.dg/special/load-category-1a.m22
-rw-r--r--gcc/testsuite/objc.dg/special/special.exp29
5 files changed, 118 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f597a9..007baf4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR libobjc/16110
+ * objc.dg/special/special.exp: Added new test.
+ * objc.dg/special/load-category-1.m: New.
+ * objc.dg/special/load-category-1a.m: New.
+ * objc.dg/special/load-category-1.h: New.
+
2010-12-21 Steven Bosscher <steven@gcc.gnu.org>
PR middle-end/45310
diff --git a/gcc/testsuite/objc.dg/special/load-category-1.h b/gcc/testsuite/objc.dg/special/load-category-1.h
new file mode 100644
index 0000000..7810487
--- /dev/null
+++ b/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/testsuite/objc.dg/special/load-category-1.m b/gcc/testsuite/objc.dg/special/load-category-1.m
new file mode 100644
index 0000000..bfd6373
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/load-category-1.m
@@ -0,0 +1,40 @@
+/* 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 <objc/runtime.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/testsuite/objc.dg/special/load-category-1a.m b/gcc/testsuite/objc.dg/special/load-category-1a.m
new file mode 100644
index 0000000..f516e7d
--- /dev/null
+++ b/gcc/testsuite/objc.dg/special/load-category-1a.m
@@ -0,0 +1,22 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.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/testsuite/objc.dg/special/special.exp b/gcc/testsuite/objc.dg/special/special.exp
index fdc90ec..dd44380 100644
--- a/gcc/testsuite/objc.dg/special/special.exp
+++ b/gcc/testsuite/objc.dg/special/special.exp
@@ -1,5 +1,5 @@
# GCC Objective-C testsuite that uses the `dg.exp' driver.
-# Copyright (C) 1997, 2001, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2001, 2007, 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
@@ -56,6 +56,33 @@ if ![string match "" $lines] then {
}
}
+#
+# 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
+}
+}
+
# All done.
dg-finish