public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* i386.c warnings cleanup
@ 1998-02-09 19:27 Marc Lehmann
  1998-02-09 19:49 ` Ian Lance Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Marc Lehmann @ 1998-02-09 19:27 UTC (permalink / raw)
  To: egcs

This patch fixes all but two -Wall warnings in config/i386/i386.c

comments appreciated ;)

Sun Feb  8 17:35:38 CET 1998  Marc Lehmann <pcg@goof.com>

	* config/i386/i386.c: Added prototypes for error, atoi,
	bcopy, set_float_handler, free.  Added include for recog.h. 
	(override_options): Removed unused variable p. Initialized regno to
	avoid warning.
	(order_regs_for_local_alloc): Initialized regno to avoid warning.
	(legitimize_address): Likewise for 'other'.
	(print_operand): Fixed format string.
	(i386_aligned_reg_p): Added default case with abort ().
	(print_operand): Likewise.
	(reg_mentioned_in_mem): Likewise.
	(ix86_expand_binary_operator): Removed unused variables i & insn.
	(ix86_expand_unary_operator): Removed unused variable insn.
	(output_fp_cc0_set): Removed unused variable unordered_label.

Index: gcc/config/i386/i386.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 i386.c
--- i386.c	1998/01/26 22:59:56	1.9
+++ i386.c	1998/02/10 03:14:11
@@ -35,6 +35,7 @@ Boston, MA 02111-1307, USA. */
 #include "flags.h"
 #include "except.h"
 #include "function.h"
+#include "recog.h"
 
 #ifdef EXTRA_CONSTRAINT
 /* If EXTRA_CONSTRAINT is defined, then the 'S'
@@ -105,6 +106,12 @@ struct processor_costs *ix86_cost = &pen
 extern FILE *asm_out_file;
 extern char *strcat ();
 
+extern void error PVPROTO((char *s, ...));
+extern int atoi PROTO((char *));
+extern void bcopy PROTO((void *, void *, int n));
+extern void set_float_handler PROTO((jmp_buf));
+extern void free PROTO((void *));
+
 static void ix86_epilogue PROTO((int));
 static void ix86_prologue PROTO((int));
 
@@ -193,8 +200,7 @@ int i386_align_jumps;
 void
 override_options ()
 {
-  int ch, i, j, regno;
-  char *p;
+  int ch, i, j;
   int def_align;
 
   static struct ptt
@@ -225,6 +231,8 @@ override_options ()
     {
       for (i = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++)
 	{
+	  int regno = 0;
+	  
 	  switch (ch)
 	    {
 	    case 'a':	regno = 0;	break;
@@ -372,7 +380,7 @@ override_options ()
 void
 order_regs_for_local_alloc ()
 {
-  int i, ch, order, regno;
+  int i, ch, order;
 
   /* User specified the register allocation order.  */
 
@@ -380,6 +388,8 @@ order_regs_for_local_alloc ()
     {
       for (i = order = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++)
 	{
+	  int regno = 0;
+	  
 	  switch (ch)
 	    {
 	    case 'a':	regno = 0;	break;
@@ -489,6 +499,9 @@ i386_aligned_p (op)
 
     case REG:
       return i386_aligned_reg_p (REGNO (op));
+    
+    default:
+      abort ();
     }
 
   return 0;
@@ -1722,8 +1735,6 @@ ix86_expand_binary_operator (code, mode,
      enum machine_mode mode;
      rtx operands[];
 {
-  rtx insn;
-  int i;
   int modified;
 
   /* Recognize <var1> = <value> <op> <var1> for commutative operators */
@@ -1823,8 +1834,6 @@ ix86_expand_unary_operator (code, mode, 
      enum machine_mode mode;
      rtx operands[];
 {
-  rtx insn;
-
   /* If optimizing, copy to regs to improve CSE */
   if (TARGET_PSEUDO
       && optimize
@@ -2841,7 +2850,8 @@ legitimize_address (x, oldx, mode)
 	       && GET_CODE (XEXP (XEXP (x, 0), 1)) == PLUS
 	       && CONSTANT_P (XEXP (x, 1)))
 	{
-	  rtx constant, other;
+	  rtx constant;
+	  rtx other = NULL_RTX;
 
 	  if (GET_CODE (XEXP (x, 1)) == CONST_INT)
 	    {
@@ -3263,10 +3273,12 @@ print_operand (file, x, code)
 	    case GTU: fputs ("jne",  file); return;
 	    case LEU: fputs ("je", file); return;
 	    case LTU: fputs ("#branch never",  file); return;
-
+	    
 	    /* no matching branches for GT nor LE */
+	    
+	    default:
+	      abort ();
 	    }
-	  abort ();
 
 	case 's':
 	  if (GET_CODE (x) == CONST_INT || ! SHIFT_DOUBLE_OMITS_COUNT)
@@ -3332,7 +3344,7 @@ print_operand (file, x, code)
       REAL_VALUE_FROM_CONST_DOUBLE (r, x);
       REAL_VALUE_TO_TARGET_SINGLE (r, l);
       PRINT_IMMED_PREFIX (file);
-      fprintf (file, "0x%x", l);
+      fprintf (file, "0x%lx", l);
     }
 
  /* These float cases don't actually occur as immediate operands. */
@@ -4036,7 +4048,6 @@ output_fp_cc0_set (insn)
      rtx insn;
 {
   rtx xops[3];
-  rtx unordered_label;
   rtx next;
   enum rtx_code code;
 
@@ -4821,6 +4832,8 @@ reg_mentioned_in_mem (reg, rtl)
     case CC0:
     case SUBREG:
       return 0;
+    default:
+      abort ();
     }
 
   if (code == MEM && reg_mentioned_p (reg, rtl))


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-09 19:27 i386.c warnings cleanup Marc Lehmann
@ 1998-02-09 19:49 ` Ian Lance Taylor
  1998-02-10  0:53   ` Jeffrey A Law
  1998-02-10  3:34 ` Robert Lipe
  1998-02-11  0:47 ` Jeffrey A Law
  2 siblings, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 1998-02-09 19:49 UTC (permalink / raw)
  To: pcg; +Cc: egcs

   Date: Tue, 10 Feb 1998 04:15:43 +0100
   From: Marc Lehmann <pcg@goof.com>

   +extern void error PVPROTO((char *s, ...));
   +extern int atoi PROTO((char *));
   +extern void bcopy PROTO((void *, void *, int n));
   +extern void set_float_handler PROTO((jmp_buf));
   +extern void free PROTO((void *));

It's safest to never declare system functions, but to instead get the
declarations from system header files.  That's because on old systems
you can't predict how the functions will be declared.  For example,
the SunOS <stdlib.h> declares free as returning int.

You should instead simply include the correct header files, and trust
them.

Ian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-09 19:49 ` Ian Lance Taylor
@ 1998-02-10  0:53   ` Jeffrey A Law
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey A Law @ 1998-02-10  0:53 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: pcg, egcs

  In message < 199802100349.WAA07459@subrogation.cygnus.com >you write:
  >    Date: Tue, 10 Feb 1998 04:15:43 +0100
  >    From: Marc Lehmann <pcg@goof.com>
  > 
  >    +extern void error PVPROTO((char *s, ...));
  >    +extern int atoi PROTO((char *));
  >    +extern void bcopy PROTO((void *, void *, int n));
  >    +extern void set_float_handler PROTO((jmp_buf));
  >    +extern void free PROTO((void *));
  > 
  > It's safest to never declare system functions, but to instead get the
  > declarations from system header files.  That's because on old systems
  > you can't predict how the functions will be declared.  For example,
  > the SunOS <stdlib.h> declares free as returning int.
  > 
  > You should instead simply include the correct header files, and trust
  > them.
Agreed.  And if a prototype is absolutely necessary then you
make it conditional on NEED_DECLARATION_xxxxx

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-09 19:27 i386.c warnings cleanup Marc Lehmann
  1998-02-09 19:49 ` Ian Lance Taylor
@ 1998-02-10  3:34 ` Robert Lipe
  1998-02-11  0:47   ` Marc Lehmann
  1998-02-11  0:47 ` Jeffrey A Law
  2 siblings, 1 reply; 7+ messages in thread
From: Robert Lipe @ 1998-02-10  3:34 UTC (permalink / raw)
  To: Marc Lehmann, egcs

> This patch fixes all but two -Wall warnings in config/i386/i386.c

Lovely.  Thank you.

> +extern void error PVPROTO((char *s, ...));
> +extern void set_float_handler PROTO((jmp_buf));

There needs to be some gcc header file that contians protos for things
like error() that are essentially globals.

> +extern int atoi PROTO((char *));
> +extern void free PROTO((void *));
> +extern void bcopy PROTO((void *, void *, int n));

But what if bcopy accepts const void pointers?   What if free() returns
an int? (this was common practice long ago). 

We should avoid divinely knowing what we think are the correct protos
for system functions.   'Tis better to use what the system gives us.

How would you feel about getting the protos for the first two via:

#if HAVE_STDLIB_H
#include <stdlib.h>
#endif

The last one seems to find favor in this technique, though I don't
recall seeing any counter that this doesn't work well for all cases:

#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif



RJL

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-09 19:27 i386.c warnings cleanup Marc Lehmann
  1998-02-09 19:49 ` Ian Lance Taylor
  1998-02-10  3:34 ` Robert Lipe
@ 1998-02-11  0:47 ` Jeffrey A Law
  2 siblings, 0 replies; 7+ messages in thread
From: Jeffrey A Law @ 1998-02-11  0:47 UTC (permalink / raw)
  To: Marc Lehmann; +Cc: egcs

  In message < 19980210041543.12242@cerebro.laendle >you write:
  > comments appreciated ;)
As other folks noted, we're better off including the appropriate
files instead of declaring things like error, bcopy, free, etc.

When declarations are absolutely needed they should be wrapped
inside autoconf #ifdefs.

jfc made some fixes to the formatting strings in i386.md, so I
didn't install that part of your patch.  If we still need the
format change after both of your patches it can be resubmitted :-)

I installed the rest of the changes.  Thanks!

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-10  3:34 ` Robert Lipe
@ 1998-02-11  0:47   ` Marc Lehmann
  1998-02-12  2:36     ` Jeffrey A Law
  0 siblings, 1 reply; 7+ messages in thread
From: Marc Lehmann @ 1998-02-11  0:47 UTC (permalink / raw)
  To: egcs

On Mon, Feb 09, 1998 at 10:55:09PM -0600, Robert Lipe wrote:
> > This patch fixes all but two -Wall warnings in config/i386/i386.c
> 
> Lovely.  Thank you.

Here's the revised version, using:

> #if HAVE_STDLIB_H
> #include <stdlib.h>
> #endif
> 
> #ifdef HAVE_STRING_H
> #include <string.h>
> #else
> #ifdef HAVE_STRINGS_H
> #include <strings.h>
> #endif
> #endif

Better? ;)

Sun Feb  8 17:35:38 CET 1998  Marc Lehmann <pcg@goof.com>

	* config/i386/i386.c: Added prototypes for error, atoi,
	bcopy, set_float_handler, free.  Added include for recog.h. 
	(override_options): Removed unused variable p. Initialized regno to
	avoid warning.
	(order_regs_for_local_alloc): Initialized regno to avoid warning.
	(legitimize_address): Likewise for 'other'.
	(print_operand): Fixed format string.
	(i386_aligned_reg_p): Added default case with abort ().
	(print_operand): Likewise.
	(reg_mentioned_in_mem): Likewise.
	(ix86_expand_binary_operator): Removed unused variables i & insn.
	(ix86_expand_unary_operator): Removed unused variable insn.
	(output_fp_cc0_set): Removed unused variable unordered_label.

Index: gcc/config/i386/i386.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 i386.c
--- i386.c	1998/01/26 22:59:56	1.9
+++ i386.c	1998/02/10 03:14:11
@@ -35,6 +35,7 @@ Boston, MA 02111-1307, USA. */
 #include "flags.h"
 #include "except.h"
 #include "function.h"
+#include "recog.h"
 
 #ifdef EXTRA_CONSTRAINT
 /* If EXTRA_CONSTRAINT is defined, then the 'S'
@@ -105,6 +106,20 @@ struct processor_costs *ix86_cost = &pen
 extern FILE *asm_out_file;
 extern char *strcat ();
 
+extern void error PVPROTO((char *s, ...));
+extern void set_float_handler PROTO((jmp_buf));
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>                                                
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>                                                   
+#else                                                  
+#ifdef HAVE_STRINGS_H
+#include <strings.h>               
+#endif                                                                   
+#endif                                                                   
+
 static void ix86_epilogue PROTO((int));
 static void ix86_prologue PROTO((int));
 
@@ -193,8 +200,7 @@ int i386_align_jumps;
 void
 override_options ()
 {
-  int ch, i, j, regno;
-  char *p;
+  int ch, i, j;
   int def_align;
 
   static struct ptt
@@ -225,6 +231,8 @@ override_options ()
     {
       for (i = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++)
 	{
+	  int regno = 0;
+	  
 	  switch (ch)
 	    {
 	    case 'a':	regno = 0;	break;
@@ -372,7 +380,7 @@ override_options ()
 void
 order_regs_for_local_alloc ()
 {
-  int i, ch, order, regno;
+  int i, ch, order;
 
   /* User specified the register allocation order.  */
 
@@ -380,6 +388,8 @@ order_regs_for_local_alloc ()
     {
       for (i = order = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++)
 	{
+	  int regno = 0;
+	  
 	  switch (ch)
 	    {
 	    case 'a':	regno = 0;	break;
@@ -489,6 +499,9 @@ i386_aligned_p (op)
 
     case REG:
       return i386_aligned_reg_p (REGNO (op));
+    
+    default:
+      abort ();
     }
 
   return 0;
@@ -1722,8 +1735,6 @@ ix86_expand_binary_operator (code, mode,
      enum machine_mode mode;
      rtx operands[];
 {
-  rtx insn;
-  int i;
   int modified;
 
   /* Recognize <var1> = <value> <op> <var1> for commutative operators */
@@ -1823,8 +1834,6 @@ ix86_expand_unary_operator (code, mode, 
      enum machine_mode mode;
      rtx operands[];
 {
-  rtx insn;
-
   /* If optimizing, copy to regs to improve CSE */
   if (TARGET_PSEUDO
       && optimize
@@ -2841,7 +2850,8 @@ legitimize_address (x, oldx, mode)
 	       && GET_CODE (XEXP (XEXP (x, 0), 1)) == PLUS
 	       && CONSTANT_P (XEXP (x, 1)))
 	{
-	  rtx constant, other;
+	  rtx constant;
+	  rtx other = NULL_RTX;
 
 	  if (GET_CODE (XEXP (x, 1)) == CONST_INT)
 	    {
@@ -3263,10 +3273,12 @@ print_operand (file, x, code)
 	    case GTU: fputs ("jne",  file); return;
 	    case LEU: fputs ("je", file); return;
 	    case LTU: fputs ("#branch never",  file); return;
-
+	    
 	    /* no matching branches for GT nor LE */
+	    
+	    default:
+	      abort ();
 	    }
-	  abort ();
 
 	case 's':
 	  if (GET_CODE (x) == CONST_INT || ! SHIFT_DOUBLE_OMITS_COUNT)
@@ -3332,7 +3344,7 @@ print_operand (file, x, code)
       REAL_VALUE_FROM_CONST_DOUBLE (r, x);
       REAL_VALUE_TO_TARGET_SINGLE (r, l);
       PRINT_IMMED_PREFIX (file);
-      fprintf (file, "0x%x", l);
+      fprintf (file, "0x%lx", l);
     }
 
  /* These float cases don't actually occur as immediate operands. */
@@ -4036,7 +4048,6 @@ output_fp_cc0_set (insn)
      rtx insn;
 {
   rtx xops[3];
-  rtx unordered_label;
   rtx next;
   enum rtx_code code;
 
@@ -4821,6 +4832,8 @@ reg_mentioned_in_mem (reg, rtl)
     case CC0:
     case SUBREG:
       return 0;
+    default:
+      abort ();
     }
 
   if (code == MEM && reg_mentioned_p (reg, rtl))


      -----==-                                              |
      ----==-- _                                            |
      ---==---(_)__  __ ____  __       Marc Lehmann       +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com       |e|
      -=====/_/_//_/\_,_/ /_/\_\                          --+
    The choice of a GNU generation                        |
                                                          |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: i386.c warnings cleanup
  1998-02-11  0:47   ` Marc Lehmann
@ 1998-02-12  2:36     ` Jeffrey A Law
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey A Law @ 1998-02-12  2:36 UTC (permalink / raw)
  To: Marc Lehmann; +Cc: egcs

  In message < 19980211071542.09104@cerebro.laendle >you write:
  > +extern void error PVPROTO((char *s, ...));
  > +extern void set_float_handler PROTO((jmp_buf));
In general, I think these belong in some gcc header, instead of
being prototyped in all the files that might use them.  I don't
know which one would be best, you'd have to look around for a
good spot.

  >  	case 's':
  >  	  if (GET_CODE (x) == CONST_INT || ! SHIFT_DOUBLE_OMITS_COUNT)
  > @@ -3332,7 +3344,7 @@ print_operand (file, x, code)
  >        REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  >        REAL_VALUE_TO_TARGET_SINGLE (r, l);
  >        PRINT_IMMED_PREFIX (file);
  > -      fprintf (file, "0x%x", l);
  > +      fprintf (file, "0x%lx", l);
This is the hunk I referred to yesterday that may not be necessary anymore
due to jfc's changes.

I installed the stdlib/string/strings change today.  The rest were installed
yesterday.

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1998-02-12  2:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-09 19:27 i386.c warnings cleanup Marc Lehmann
1998-02-09 19:49 ` Ian Lance Taylor
1998-02-10  0:53   ` Jeffrey A Law
1998-02-10  3:34 ` Robert Lipe
1998-02-11  0:47   ` Marc Lehmann
1998-02-12  2:36     ` Jeffrey A Law
1998-02-11  0:47 ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).