This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch installed to libiberty to turn on -pedantic


While attempting to bootstrap on solaris2 using cc, I ran into some
more problems in cp-demangle.c.  Basically there were two issues.
First we had some prototypes which had two semi-colons at the end of
the line.  E.g. "extern void foo();;"

We also had some function prototypes with a char argument, but the
functions definition was in traditional style.  E.g.
 > extern void foo(char);
 > void foo(c)
 >   char c;
 > {
 > }

ANSI C accepts neither construct but gcc does as an extension.  Since
-pedantic would have caught both problems, I added it to the flags
libiberty uses and cleaned up some other warnings in the process.  I
tested by compiling libiberty on on solaris2.7 with cc and x86-linux
with gcc.

I installed the following patch:

2000-06-07  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

libiberty:
	* configure.in (ac_libiberty_warn_cflags): Add -pedantic.
	
	* choose-temp.c (try, choose_temp_base, make_temp_file): Constify.

	* cp-demangle.c (demangle_char): Change parameter from char to int.
	(demangle_expression, demangle_expr_primary): Remove extra
	semi-colon in prototype.

	* dyn-string.c (dyn_string_append_char): Change parameter from
	char to int.

	* memcmp.c (memcmp): Constify.

	* mkstemps.c (gcc_uint64_t): Mark GNUC `long long' case with
	__extension__.

	* partition.c (elem_compare): Prototype.  Don't cast away
	const-ness.

	* setenv.c (setenv): Use braces to avoid ambiguous `else'.
	
include:
	* demangle.h (demangling_styles): Remove trailing comma in enum.

	* dyn-string.h (dyn_string_append_char): Change parameter from
	char to int.

diff -rup orig/egcs-CVS20000607/libiberty/configure.in egcs-CVS20000607/libiberty/configure.in
--- orig/egcs-CVS20000607/libiberty/configure.in	Thu Apr 27 21:33:56 2000
+++ egcs-CVS20000607/libiberty/configure.in	Wed Jun  7 14:32:25 2000
@@ -55,7 +55,7 @@ AC_PROG_CC_GNU
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_libiberty_warn_cflags='-W -Wall -Wtraditional'
+  ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
 dnl Check whether -g works, even if CFLAGS is set, in case the package
 dnl plays around with CFLAGS (such as to build both debugging and
 dnl normal versions of a library), tasteless as that idea is.
diff -rup orig/egcs-CVS20000607/libiberty/choose-temp.c egcs-CVS20000607/libiberty/choose-temp.c
--- orig/egcs-CVS20000607/libiberty/choose-temp.c	Sat Sep 25 09:11:12 1999
+++ egcs-CVS20000607/libiberty/choose-temp.c	Wed Jun  7 14:38:37 2000
@@ -79,9 +79,11 @@ extern int mkstemps ();
    If success, DIR is returned.
    Otherwise NULL is returned.  */
 
-static char *
+static const char *try PARAMS ((const char *, const char *));
+
+static const char *
 try (dir, base)
-     char *dir, *base;
+     const char *dir, *base;
 {
   if (base != 0)
     return base;
@@ -102,7 +104,7 @@ try (dir, base)
 char *
 choose_temp_base ()
 {
-  char *base = 0;
+  const char *base = 0;
   char *temp_filename;
   int len;
   static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
@@ -147,7 +149,7 @@ char *
 make_temp_file (suffix)
      const char *suffix;
 {
-  char *base = 0;
+  const char *base = 0;
   char *temp_filename;
   int base_len, suffix_len;
   int fd;
diff -rup orig/egcs-CVS20000607/libiberty/cp-demangle.c egcs-CVS20000607/libiberty/cp-demangle.c
--- orig/egcs-CVS20000607/libiberty/cp-demangle.c	Wed Jun  7 16:01:44 2000
+++ egcs-CVS20000607/libiberty/cp-demangle.c	Wed Jun  7 14:32:06 2000
@@ -713,7 +713,7 @@ demangling_delete (dm)
    structure.  */
 
 static status_t demangle_char
-  PARAMS ((demangling_t, char));
+  PARAMS ((demangling_t, int));
 static status_t demangle_mangled_name 
   PARAMS ((demangling_t));
 static status_t demangle_encoding
@@ -765,11 +765,11 @@ static status_t demangle_literal
 static status_t demangle_template_arg
   PARAMS ((demangling_t));
 static status_t demangle_expression
-  PARAMS ((demangling_t));;
+  PARAMS ((demangling_t));
 static status_t demangle_scope_expression
   PARAMS ((demangling_t));
 static status_t demangle_expr_primary
-  PARAMS ((demangling_t));;
+  PARAMS ((demangling_t));
 static status_t demangle_substitution
   PARAMS ((demangling_t, int *, int *));
 static status_t demangle_local_name
@@ -789,7 +789,7 @@ static status_t cp_demangle
 static status_t
 demangle_char (dm, c)
      demangling_t dm;
-     char c;
+     int c;
 {
   static char *error_message = NULL;
 
diff -rup orig/egcs-CVS20000607/libiberty/dyn-string.c egcs-CVS20000607/libiberty/dyn-string.c
--- orig/egcs-CVS20000607/libiberty/dyn-string.c	Sun Jun  4 22:28:41 2000
+++ egcs-CVS20000607/libiberty/dyn-string.c	Wed Jun  7 14:43:50 2000
@@ -275,7 +275,7 @@ dyn_string_append_cstr (ds, s)
 dyn_string_t 
 dyn_string_append_char (ds, c)
      dyn_string_t ds;
-     char c;
+     int c;
 {
   /* Make room for the extra character.  */
   dyn_string_resize (ds, ds->length + 1);
diff -rup orig/egcs-CVS20000607/libiberty/memcmp.c egcs-CVS20000607/libiberty/memcmp.c
--- orig/egcs-CVS20000607/libiberty/memcmp.c	Fri May 15 19:14:20 1998
+++ egcs-CVS20000607/libiberty/memcmp.c	Wed Jun  7 14:51:19 2000
@@ -25,8 +25,8 @@ int
 DEFUN(memcmp, (str1, str2, count),
       const PTR str1 AND const PTR str2 AND size_t count)
 {
-  register unsigned char *s1 = (unsigned char*)str1;
-  register unsigned char *s2 = (unsigned char*)str2;
+  register const unsigned char *s1 = (const unsigned char*)str1;
+  register const unsigned char *s2 = (const unsigned char*)str2;
 
   while (count-- > 0)
     {
diff -rup orig/egcs-CVS20000607/libiberty/mkstemps.c egcs-CVS20000607/libiberty/mkstemps.c
--- orig/egcs-CVS20000607/libiberty/mkstemps.c	Sat Sep  4 11:08:49 1999
+++ egcs-CVS20000607/libiberty/mkstemps.c	Wed Jun  7 14:42:22 2000
@@ -39,7 +39,7 @@
 
 /* We need to provide a type for gcc_uint64_t.  */
 #ifdef __GNUC__
-typedef unsigned long long gcc_uint64_t;
+__extension__ typedef unsigned long long gcc_uint64_t;
 #else
 typedef unsigned long gcc_uint64_t;
 #endif
diff -rup orig/egcs-CVS20000607/libiberty/partition.c egcs-CVS20000607/libiberty/partition.c
--- orig/egcs-CVS20000607/libiberty/partition.c	Tue May 30 10:20:14 2000
+++ egcs-CVS20000607/libiberty/partition.c	Wed Jun  7 14:40:24 2000
@@ -34,6 +34,8 @@
 #include "libiberty.h"
 #include "partition.h"
 
+static int elem_compare PARAMS ((const void *, const void *));
+
 /* Creates a partition of NUM_ELEMENTS elements.  Initially each
    element is in a class by itself.  */
 
@@ -128,8 +130,8 @@ elem_compare (elem1, elem2)
      const void *elem1;
      const void *elem2;
 {
-  int e1 = * (int *) elem1;
-  int e2 = * (int *) elem2;
+  int e1 = * (const int *) elem1;
+  int e2 = * (const int *) elem2;
   if (e1 < e2)
     return -1;
   else if (e1 > e2)
diff -rup orig/egcs-CVS20000607/libiberty/setenv.c egcs-CVS20000607/libiberty/setenv.c
--- orig/egcs-CVS20000607/libiberty/setenv.c	Mon Oct 18 07:42:39 1999
+++ egcs-CVS20000607/libiberty/setenv.c	Wed Jun  7 14:41:18 2000
@@ -72,11 +72,13 @@ setenv (name, value, replace)
 
   size = 0;
   if (__environ != NULL)
-    for (ep = __environ; *ep != NULL; ++ep)
-      if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
-	break;
-      else
-	++size;
+    {
+      for (ep = __environ; *ep != NULL; ++ep)
+	if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+	  break;
+	else
+	  ++size;
+    }
 
   if (__environ == NULL || *ep == NULL)
     {
diff -rup orig/egcs-CVS20000607/include/demangle.h egcs-CVS20000607/include/demangle.h
--- orig/egcs-CVS20000607/include/demangle.h	Mon Jun  5 10:23:52 2000
+++ egcs-CVS20000607/include/demangle.h	Wed Jun  7 14:42:51 2000
@@ -59,7 +59,7 @@ extern enum demangling_styles
   arm_demangling = DMGL_ARM,
   hp_demangling = DMGL_HP,
   edg_demangling = DMGL_EDG,
-  gnu_new_abi_demangling = DMGL_GNU_NEW_ABI,
+  gnu_new_abi_demangling = DMGL_GNU_NEW_ABI
 } current_demangling_style;
 
 /* Define string names for the various demangling styles. */
diff -rup orig/egcs-CVS20000607/include/dyn-string.h egcs-CVS20000607/include/dyn-string.h
--- orig/egcs-CVS20000607/include/dyn-string.h	Sun Jun  4 22:28:41 2000
+++ egcs-CVS20000607/include/dyn-string.h	Wed Jun  7 14:44:06 2000
@@ -58,7 +58,7 @@ extern dyn_string_t dyn_string_append   
 extern dyn_string_t dyn_string_append_cstr   
                                         PARAMS ((dyn_string_t, const char *));
 extern dyn_string_t dyn_string_append_char
-                                        PARAMS ((dyn_string_t, char));
+                                        PARAMS ((dyn_string_t, int));
 extern void dyn_string_substring        PARAMS ((dyn_string_t, 
 						 dyn_string_t, int, int));
 extern int dyn_string_eq                PARAMS ((dyn_string_t, dyn_string_t));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]