Fix for PR objc/47314

Nicola Pero nicola.pero@meta-innovation.com
Sun Jan 16 17:06:00 GMT 2011


While rewriting some ObjC code for performance - a work that I'll submit for GCC 4.7 -
I spotted a typo in the existing 4.6 code, which causes GCC 4.6 to produce an incorrect
message when -Wselector is used to check for duplicate methods.  The error produced is

  warning: multiple selectors named ‘+method’ found

while it should be

  warning: multiple selectors named ‘-method’ found

It seems worthwhile to apply ("backport") this trivial one-liner bug fix to GCC 4.6,
so I'm submitting it as GCC 4.6 patch.

Ok to commit ?

Thanks

Index: objc/objc-act.c
===================================================================
--- objc/objc-act.c     (revision 168850)
+++ objc/objc-act.c     (working copy)
@@ -12986,7 +12986,7 @@
          for (hsh = cls_method_hash_list[slot]; hsh; hsh = hsh->next)
            check_duplicates (hsh, 0, 1);
          for (hsh = nst_method_hash_list[slot]; hsh; hsh = hsh->next)
-           check_duplicates (hsh, 0, 1);
+           check_duplicates (hsh, 0, 0);
        }
     }
 
Index: objc/ChangeLog
===================================================================
--- objc/ChangeLog      (revision 168850)
+++ objc/ChangeLog      (working copy)
@@ -1,3 +1,9 @@
+2011-01-16  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR objc/47314
+       * objc-act.c (finish_objc): When calling check_duplicates to check
+       duplicated instance methods, set 'is_class' to 0, not 1.
+
 2011-01-14  Ben Elliston  <bje@au.ibm.com>
 
        PR 19162
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 168850)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2011-01-16  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR objc/47314
+       * objc.dg/selector-warn-1.m: New.
+       * obj-c++.dg/selector-warn-1.mm: New.
+
 2011-01-13  Jan Hubicka  <jh@suse.cz>
 
        PR tree-optimization/47276 
Index: testsuite/objc.dg/selector-warn-1.m
===================================================================
--- testsuite/objc.dg/selector-warn-1.m (revision 0)
+++ testsuite/objc.dg/selector-warn-1.m (revision 0)
@@ -0,0 +1,16 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, January 2011.  */
+/* { dg-options "-Wselector" } */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface RootObject
+@end
+
+@interface MyObject : RootObject
+- (void) method; /* { dg-message "found" } */
+@end
+
+@interface MyObject2  : RootObject
+- (int) method; /* { dg-message "also found" } */
+@end /* { dg-warning "multiple selectors named .-method. found" } */
Index: testsuite/obj-c++.dg/selector-warn-1.mm
===================================================================
--- testsuite/obj-c++.dg/selector-warn-1.mm     (revision 0)
+++ testsuite/obj-c++.dg/selector-warn-1.mm     (revision 0)
@@ -0,0 +1,16 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, January 2011.  */
+/* { dg-options "-Wselector" } */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface RootObject
+@end
+
+@interface MyObject : RootObject
+- (void) method; /* { dg-message "found" } */
+@end
+
+@interface MyObject2  : RootObject
+- (int) method; /* { dg-message "also found" } */
+@end /* { dg-warning "multiple selectors named .-method. found" } */




More information about the Gcc-patches mailing list