aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-12-21 13:44:04 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-12-21 13:44:04 +0000
commitc75534d1e6e8b62ea4dabf58c2deff1ac09796a7 (patch)
tree7f571fa1e6bfcad3a54cae1509897fe496642bfa /gcc
parentcb227aa9ab85856f4906ff49caef1bcee87ec643 (diff)
downloadgcc-c75534d1e6e8b62ea4dabf58c2deff1ac09796a7.zip
gcc-c75534d1e6e8b62ea4dabf58c2deff1ac09796a7.tar.gz
gcc-c75534d1e6e8b62ea4dabf58c2deff1ac09796a7.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/45953 * selector.c (__sel_register_typed_name): When registering a new selector with the same name as an existing one, reuse the existing name string. Also updated types, casts and comments in the whole function. In gcc/testsuite/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/45953 * objc.dg/libobjc-selector-1.m: New test. From-SVN: r168115
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/objc.dg/libobjc-selector-1.m39
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7b97962..50cfa32 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR libobjc/45953
+ * objc.dg/libobjc-selector-1.m: New test.
+
2010-12-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/45852
diff --git a/gcc/testsuite/objc.dg/libobjc-selector-1.m b/gcc/testsuite/objc.dg/libobjc-selector-1.m
new file mode 100644
index 0000000..49947d7
--- /dev/null
+++ b/gcc/testsuite/objc.dg/libobjc-selector-1.m
@@ -0,0 +1,39 @@
+/* Test a little inefficiency that was fixed in libobjc when dealing
+ with selectors (PR libobjc/45953). */
+
+/* { dg-do run } */
+/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+
+/* To get the modern GNU Objective-C Runtime API, you include
+ objc/runtime.h. */
+#include <objc/runtime.h>
+#include <stdlib.h>
+
+/* Test that registering a new selector, with the same name but a
+ different type than the previous one, does not change the original
+ name string. It is actually fine to change it (there is no
+ guarantee that it won't change), except for runtime performance /
+ memory consumption, since changing it means that the runtime is
+ doing an unneeded objc_malloc()/strcpy(), which is inefficient. */
+
+int main (void)
+{
+ SEL selector_1;
+ SEL selector_2;
+ const char *name_1;
+ const char *name_2;
+
+ /* These method type strings may well be invalid. Please don't use
+ them as examples. They are irrelevant for this test; any string
+ will do. */
+ selector_1 = sel_registerTypedName ("method", "v@:");
+ name_1 = sel_getName (selector_1);
+
+ selector_2 = sel_registerTypedName ("method", "i@:");
+ name_2 = sel_getName (selector_1);
+
+ if (name_1 != name_2)
+ abort ();
+
+ return 0;
+}