Patch for remaining warnings in libobjc

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Wed Jun 19 07:42:00 GMT 2002


This patch targets all the remaining warnings arising from the libobjc
directory.  (At least those I get on my test platform.)  Some notes:

1.  Adding attribute unused to the parser for objc method parameters
    was more complicated than I expected.  So for now I simply "used"
    the parameters in a do-nothing statement (see Object.m.)

2.  I still get warnings about the unused `target_flags' even though I
    adding attribute unused to it.  However I think this is a bug in
    gcc.  I'd still like to add the attribute and pursue a fix in cc1.

3.  We were using libc/stdlib.h atoi in archive.c but provided our own
    inline function in encoding.c.  It doesn't fix a warning but I
    felt libobjc didn't need its own implementation so I deleted it.

4.  I don't know if it's safe to change __objc_selector_max_index to
    unsigned but I audited the code wherever it's being used and it
    looks okay.  I.e. it's initialized to zero and only incremented,
    and used as a size indicator.  But I wanted to draw your attention
    in case there's something I missed.

The patch eliminates these warnings:

 > libobjc/Object.m:273: warning: unused parameter `argFrame'
 > libobjc/Object.m:366: warning: unused parameter `aStream'
 > libobjc/Object.m:372: warning: unused parameter `aStream'
 > libobjc/selector.c:295: warning: comparison between signed and unsigned
 > libobjc/selector.c:307: warning: comparison between signed and unsigned
 > libobjc/sendmsg.c:295: warning: implicit declaration of function `__objc_generate_gc_type_description'

Only this one remains, see note #2.

 > libobjc/encoding.c:83: warning: `target_flags' defined but not used


Tested on sparc-sun-solaris2.7, no objc regressions.  Okay to install?

		Thanks,
		--Kaveh


2002-06-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* Object.m (forward, read, write): Fix unused parameter warnings.
	* encoding.c: Include <stdlib.h>.
	(target_flags): Mark with attribute unused.
	(atoi): Delete.
	* runtime.h (__objc_selector_max_index): Change to unsigned int.
	(__objc_generate_gc_type_description): Prototype.
	* selector.c (__objc_selector_max_index): Change to unsigned int.

diff -rup orig/egcc-CVS20020618/libobjc/Object.m egcc-CVS20020618/libobjc/Object.m
--- orig/egcc-CVS20020618/libobjc/Object.m	2002-06-15 13:47:43.000000000 -0400
+++ egcc-CVS20020618/libobjc/Object.m	2002-06-18 23:48:00.947959100 -0400
@@ -1,5 +1,5 @@
 /* The implementation of class Object for Objective-C.
-   Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1997, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -271,6 +271,7 @@ extern int errno;
 
 - (retval_t)forward:(SEL)aSel :(arglist_t)argFrame
 {
+  (void) argFrame; /* UNUSED */
   return (retval_t)[self doesNotRecognize: aSel];
 }
 
@@ -364,12 +365,14 @@ extern int errno;
 
 - read: (TypedStream*)aStream
 {
+  (void) aStream; /* UNUSED */
   // [super read: aStream];  
   return self;
 }
 
 - write: (TypedStream*)aStream
 {
+  (void) aStream; /* UNUSED */
   // [super write: aStream];
   return self;
 }
diff -rup orig/egcc-CVS20020618/libobjc/encoding.c egcc-CVS20020618/libobjc/encoding.c
--- orig/egcc-CVS20020618/libobjc/encoding.c	2002-06-15 13:47:43.000000000 -0400
+++ egcc-CVS20020618/libobjc/encoding.c	2002-06-18 23:48:00.957958813 -0400
@@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA.  */
 #include "tconfig.h"
 #include "objc-api.h"
 #include "encoding.h"
+#include <stdlib.h>
 
 #undef  MAX
 #define MAX(X, Y)                    \
@@ -80,18 +81,7 @@ Boston, MA 02111-1307, USA.  */
 /* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
    target_flags.  Define a dummy entry here to so we don't die.  */
 
-static int target_flags = 0;
-
-static inline int
-atoi (const char* str)
-{
-  int res = 0;
-
-  while (isdigit ((unsigned char)*str))
-    res *= 10, res += (*str++ - '0');
-
-  return res;
-}
+static int __attribute__ ((__unused__)) target_flags = 0;
 
 /*
   return the size of an object specified by type
diff -rup orig/egcc-CVS20020618/libobjc/objc/runtime.h egcc-CVS20020618/libobjc/objc/runtime.h
--- orig/egcc-CVS20020618/libobjc/objc/runtime.h	1999-09-04 11:09:20.000000000 -0400
+++ egcc-CVS20020618/libobjc/objc/runtime.h	2002-06-18 23:48:00.957958813 -0400
@@ -1,5 +1,5 @@
 /* GNU Objective C Runtime internal declarations
-   Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
    Contributed by Kresten Krab Thorup
 
 This file is part of GNU CC.
@@ -65,7 +65,7 @@ extern Method_t search_for_method_in_lis
 extern BOOL __objc_class_links_resolved;
 
 /* Number of selectors stored in each of the selector  tables */
-extern int __objc_selector_max_index;
+extern unsigned int __objc_selector_max_index;
 
 /* Mutex locking __objc_selector_max_index and its arrays. */
 extern objc_mutex_t __objc_runtime_mutex;
@@ -82,6 +82,7 @@ extern int __objc_runtime_threads_alive;
 BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */
 SEL  __sel_register_typed_name (const char*, const char*, 
 				struct objc_selector*, BOOL is_const);
+extern void __objc_generate_gc_type_description (Class);
 
 #endif /* not __objc_runtime_INCLUDE_GNU */
 
diff -rup orig/egcc-CVS20020618/libobjc/selector.c egcc-CVS20020618/libobjc/selector.c
--- orig/egcc-CVS20020618/libobjc/selector.c	2002-06-15 13:47:43.000000000 -0400
+++ egcc-CVS20020618/libobjc/selector.c	2002-06-18 23:48:36.280122364 -0400
@@ -1,5 +1,5 @@
 /* GNU Objective C Runtime selector related functions
-   Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
    Contributed by Kresten Krab Thorup
 
 This file is part of GNU CC.
@@ -38,7 +38,7 @@ static cache_ptr      __objc_selector_ha
 static void register_selectors_from_list(MethodList_t);
 
 /* Number of selectors stored in each of the above tables */
-int __objc_selector_max_index = 0;              /* !T:MUTEX */
+unsigned int __objc_selector_max_index = 0;     /* !T:MUTEX */
 
 void __objc_init_selector_tables()
 {



More information about the Gcc-patches mailing list