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]

Re: Patch installed for format specifier warnings


 > From: Richard Earnshaw <rearnsha@arm.com>
 > 
 > diff -rup orig/egcc-CVS20030602/gcc/config/arm/pe.h 
 > egcc-CVS20030602/gcc/config/arm/pe.h
 > --- orig/egcc-CVS20030602/gcc/config/arm/pe.h	2003-03-13 
 > 10:00:04.000000000 -0500
 > +++ egcc-CVS20030602/gcc/config/arm/pe.h	2003-06-03 22:21:47.548556000 
 > -0400
 > @@ -147,7 +147,7 @@
 >  	  fprintf ((STREAM), "\t.comm\t"); 		\
 >  	  assemble_name ((STREAM), (NAME));		\
 >  	  asm_fprintf ((STREAM), ", %d\t%@ %d\n",	\
 > -		   (ROUNDED), (SIZE));			\
 > + 		   (int)(ROUNDED), (int)(SIZE));	\
 >  	}						\
 >      }							\
 >    while (0)
 > 
 > asm_fprintf supports %wd for printing a HOST_WIDE_INT.  Why not use that 
 > instead of casting down?
 > R.

I'm sure you are aware in the general case, when *printf parameters
derive from arguments to the containing macro itself (like above),
they need to be casted no matter what because if the macro is used in
more than one place, you may get e.g. a long "SIZE" in one place and
an int "SIZE" in another.

(It turns out that ASM_OUTPUT_COMMON is only used in one place, so
perhaps this isn't necessary for just this macro, but that precludes
it being used anywhere else ever without the casts being introduced.)

Anyway I was looking for minimally invasive changes since I am testing
this only through linking cc1 in a cross-target config.  I thought
since arm was a 32-bit target, the int cast was sufficient and
minimal.

If you want the HWI casted form, I can do this, but I cannot test it
beyond making sure it links and introduces no warnings in varasm.c.  I
did a cross-compile of cc1 targetting arm-semi-aof and arm-unknown-pe
to test this new patch.  (I believe those two configs use these
files.)

Shall I install this?

		--Kaveh


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

	* arm/aof.h (ASM_OUTPUT_COMMON, ASM_OUTPUT_LOCAL): Use asm_fprintf
	"%wd" and cast arguments to HOST_WIDE_INT.
	* arm/pe.h (ASM_OUTPUT_COMMON): Likewise.

diff -rup orig/egcc-CVS20030604/gcc/config/arm/aof.h egcc-CVS20030604/gcc/config/arm/aof.h
--- orig/egcc-CVS20030604/gcc/config/arm/aof.h	2003-06-04 13:32:08.000000000 -0400
+++ egcc-CVS20030604/gcc/config/arm/aof.h	2003-06-05 10:43:37.578246995 -0400
@@ -206,15 +206,15 @@ do					\
   (common_section (),						\
    fprintf ((STREAM), "\tAREA "),				\
    assemble_name ((STREAM), (NAME)),				\
-   fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n",	\
-	    (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
+   asm_fprintf ((STREAM), ", DATA, COMMON\n\t%% %wd\t%s size=%wd\n", \
+     (HOST_WIDE_INT)(ROUNDED), ASM_COMMENT_START, (HOST_WIDE_INT)(SIZE)))
 
 #define ASM_OUTPUT_LOCAL(STREAM,NAME,SIZE,ROUNDED)	\
    (zero_init_section (),				\
     assemble_name ((STREAM), (NAME)),			\
     fprintf ((STREAM), "\n"),				\
-    fprintf ((STREAM), "\t%% %d\t%s size=%d\n",		\
-	     (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)))
+    asm_fprintf ((STREAM), "\t%% %wd\t%s size=%wd\n",	\
+      (HOST_WIDE_INT)(ROUNDED), ASM_COMMENT_START, (HOST_WIDE_INT)(SIZE)))
 
 /* Output and Generation of Labels */
 
diff -rup orig/egcc-CVS20030604/gcc/config/arm/pe.h egcc-CVS20030604/gcc/config/arm/pe.h
--- orig/egcc-CVS20030604/gcc/config/arm/pe.h	2003-06-04 13:32:08.000000000 -0400
+++ egcc-CVS20030604/gcc/config/arm/pe.h	2003-06-05 10:44:13.186273182 -0400
@@ -146,8 +146,8 @@
 	{						\
 	  fprintf ((STREAM), "\t.comm\t"); 		\
 	  assemble_name ((STREAM), (NAME));		\
-	  asm_fprintf ((STREAM), ", %d\t%@ %d\n",	\
- 		   (int)(ROUNDED), (int)(SIZE));	\
+	  asm_fprintf ((STREAM), ", %wd\t%@ %wd\n",	\
+	    (HOST_WIDE_INT)(ROUNDED), (HOST_WIDE_INT)(SIZE)); \
 	}						\
     }							\
   while (0)


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