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 for arm/pe warnings


Here's a patch to get rid of more arm warnings from a cross compiler
to arm-unknown-pe.

I created a new general purpose macro called IN_RANGE to get rid of
the "is always true" warnings.  It also has the benefit that the macro
argument is evaluated only once.  I wasn't sure if the cast should
have been just "unsigned" or "unsigned HOST_WIDE_INT".  If its just
"unsigned" then it might possible go in ansidecl.h instead of system.h.
(Something for the reviewer to think about.)

The other thing to explain is the HOST_INT/HOST_UINT macro change.
AFAICT, these were introduced to avoid -Wtraditional warnings from
gcc-2.95 which complains about "integer is so large it is unsigned".
Gcc 3.x doesn't warn about these if the value is hex, and does warn
about using the "u" suffix, so I added a check for __GNUC__<3.  I
tested with gcc3.1, 2.95.2 and cc to make sure it did the right thing
for all cases.

Anyway, here are the warnings the patch gets rid of.  Where you see
[...] it means lots of duplicates appear.

 > config/arm/pe.h:126:1: warning: "TARGET_ASM_NAMED_SECTION" redefined
 > config/arm/coff.h:68:1: warning: this is the location of the previous definition
 > [...]
 > config/arm/arm.c:936: warning: traditional C rejects the 'u' suffix
 > [...]
 > combine.c:799: warning: comparison of unsigned expression >= 0 is always true
 > combine.c:1225: warning: comparison of unsigned expression >= 0 is always true
 > rtlanal.c:2842: warning: comparison of unsigned expression >= 0 is always true
 > varasm.c:228: warning: function declaration isn't a prototype
 > varasm.c:228: warning: function declaration isn't a prototype
 > config/arm/pe.c:270: warning: assignment discards qualifiers from pointer target type
 > config/arm/pe.c:272: warning: assignment discards qualifiers from pointer target type
 > config/arm/pe.c:274: warning: assignment discards qualifiers from pointer target type

Tested via a cross compile from sparc-sun-solaris2.7 to arm-unknown-pe.

Okay to install?

		Thanks,
		--Kaveh



2001-10-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* arm.h (FUNCTION_ARG_REGNO_P): Use IN_RANGE.
	(HOST_INT, HOST_UINT): Check ANSI_PROTOTYPES and __GNUC__<3,
	not __STDC__.

	* pe.c (arm_pe_unique_section): Const-ify.
	* pe.h (TARGET_ASM_NAMED_SECTION): Undef before defining.
	(switch_to_section): Add static prototype.

	* output.h (drectve_section): Prototype.
	* system.h (IN_RANGE): New macro.

diff -rup orig/egcs-CVS20011012/gcc/config/arm/arm.h egcs-CVS20011012/gcc/config/arm/arm.h
--- orig/egcs-CVS20011012/gcc/config/arm/arm.h	Sun Oct 14 10:56:11 2001
+++ egcs-CVS20011012/gcc/config/arm/arm.h	Sun Oct 14 10:26:51 2001
@@ -1505,8 +1505,7 @@ typedef struct
 
 /* 1 if N is a possible register number for function argument passing.
    On the ARM, r0-r3 are used to pass args.  */
-#define FUNCTION_ARG_REGNO_P(REGNO)  \
-  ((REGNO) >= 0 && (REGNO) <= 3)
+#define FUNCTION_ARG_REGNO_P(REGNO)	(IN_RANGE (0, 3, (REGNO)))
 
 
 /* Tail calling.  */
@@ -2662,9 +2661,10 @@ extern int making_const_table;
 #define PRINT_OPERAND(STREAM, X, CODE)  \
   arm_print_operand (STREAM, X, CODE)
 
-/* Create an [unsigned] host sized integer declaration that
-   avoids compiler warnings.  */
-#ifdef __STDC__
+/* Create an [unsigned] host sized integer declaration that avoids
+   compiler warnings.  Note in gcc 3.0 and above, its not necessary
+   and in fact produces even more warnings.  So only do it for < 3.0.  */
+#if defined (ANSI_PROTOTYPES) && __GNUC__ < 3
 #define HOST_INT(x)  ((signed HOST_WIDE_INT) x##UL)
 #define HOST_UINT(x) ((unsigned HOST_WIDE_INT) x##UL)
 #else
diff -rup orig/egcs-CVS20011012/gcc/config/arm/pe.c egcs-CVS20011012/gcc/config/arm/pe.c
--- orig/egcs-CVS20011012/gcc/config/arm/pe.c	Thu Sep 20 23:12:29 2001
+++ egcs-CVS20011012/gcc/config/arm/pe.c	Sun Oct 14 10:41:15 2001
@@ -257,7 +257,7 @@ arm_pe_unique_section (decl, reloc)
   int len;
   const char * name;
   char * string;
-  char * prefix;
+  const char * prefix;
 
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
   /* Strip off any encoding in fnname.  */
diff -rup orig/egcs-CVS20011012/gcc/config/arm/pe.h egcs-CVS20011012/gcc/config/arm/pe.h
--- orig/egcs-CVS20011012/gcc/config/arm/pe.h	Sat Aug  4 07:30:19 2001
+++ egcs-CVS20011012/gcc/config/arm/pe.h	Sun Oct 14 11:01:02 2001
@@ -123,6 +123,7 @@ Boston, MA 02111-1307, USA.  */
 #define SUPPORTS_ONE_ONLY 1
 
 /* Switch into a generic section.  */
+#undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
 
 /* This outputs a lot of .req's to define alias for various registers.
@@ -234,7 +235,8 @@ drectve_section ()							\
    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
    afterwards.  */
 #define SWITCH_TO_SECTION_FUNCTION				\
-void								\
+static void switch_to_section PARAMS ((enum in_section, tree)); \
+static void							\
 switch_to_section (section, decl)				\
      enum in_section section;					\
      tree decl;							\
diff -rup orig/egcs-CVS20011012/gcc/output.h egcs-CVS20011012/gcc/output.h
--- orig/egcs-CVS20011012/gcc/output.h	Thu Oct 11 16:30:27 2001
+++ egcs-CVS20011012/gcc/output.h	Sun Oct 14 10:55:37 2001
@@ -194,6 +194,10 @@ extern void fini_section PARAMS ((void))
 extern void tdesc_section PARAMS ((void));
 #endif
 
+#ifdef DRECTVE_SECTION_ASM_OP
+extern void drectve_section PARAMS ((void));
+#endif
+
 #ifdef TREE_CODE
 /* Tell assembler to change to section NAME for DECL.
    If DECL is NULL, just switch to section NAME.
diff -rup orig/egcs-CVS20011012/gcc/system.h egcs-CVS20011012/gcc/system.h
--- orig/egcs-CVS20011012/gcc/system.h	Tue Oct  9 16:30:28 2001
+++ egcs-CVS20011012/gcc/system.h	Sun Oct 14 10:26:51 2001
@@ -168,6 +168,13 @@ extern int errno;
 /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT.  */
 #include "hwint.h"
 
+/* A macro to determine whether a value is in a certain range without
+   evaluating the value more than once.  The macro won't warn if the
+   value is unsigned and the lower bound is zero, as it would
+   e.g. with "VALUE >= 0 ...".  Note neither bound can be negative.  */
+#define IN_RANGE(LOWER, UPPER, VALUE) \
+  ((unsigned HOST_WIDE_INT)(VALUE) - (LOWER) <= (UPPER))
+
 /* Infrastructure for defining missing _MAX and _MIN macros.  Note that
    macros defined with these cannot be used in #if.  */
 


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