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]
Other format: [Raw text]

Patch for warning regression in sparc.c


Richard,

Your recent patch to sparc.c:
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01894.html

+     {
+       /* Print a sign-extended 32-bit value.  */
+       HOST_WIDE_INT i;
+       if (GET_CODE(x) == CONST_INT)
+         i = INTVAL (x);
+       else if (GET_CODE(x) == CONST_DOUBLE)
+	  i = CONST_DOUBLE_LOW (x);
+       else
+	  output_operand_lossage ("invalid %%s operand");
+	i = trunc_int_for_mode (i, SImode);
+	fprintf (file, HOST_WIDE_INT_PRINT_DEC, i);
+	return;
+     }

introduced a warning:

 > sparc.c:6478: warning: `i' might be used uninitialized in this function

The function output_operand_lossage is not `noreturn', so indeed `i'
will be used uninitialized in the case where the if-else chain calls
output_operand_lossage.

I fix it by adding a return stmt after the output_operand_lossage
call.  Tested on solaris2.7, no regressions.

Ok for mainline (and 3.3 once it's unfrozen?)

		Thanks,
		--Kaveh
 

2003-05-11  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* sparc.c (print_operand): Fix uninitialized warning.

diff -rup orig/egcc-CVS20030508/gcc/config/sparc/sparc.c egcc-CVS20030508/gcc/config/sparc/sparc.c
--- orig/egcc-CVS20030508/gcc/config/sparc/sparc.c	2003-04-28 21:01:25.000000000 -0400
+++ egcc-CVS20030508/gcc/config/sparc/sparc.c	2003-05-11 14:23:44.133862000 -0400
@@ -6481,7 +6481,10 @@ print_operand (file, x, code)
 	else if (GET_CODE(x) == CONST_DOUBLE)
 	  i = CONST_DOUBLE_LOW (x);
 	else
-	  output_operand_lossage ("invalid %%s operand");
+	  {
+	    output_operand_lossage ("invalid %%s operand");
+	    return;
+	  }
 	i = trunc_int_for_mode (i, SImode);
 	fprintf (file, HOST_WIDE_INT_PRINT_DEC, i);
 	return;


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