[2/3] PPC/GAS: Correct a signed vs unsigned comparison error with GCC 4.1

Message ID alpine.LFD.2.21.1809141949130.16413@eddie.linux-mips.org
State New
Headers show
Series
  • A bunch of C89 and GCC 4.1.2 fixes
Related show

Commit Message

Maciej W. Rozycki Sept. 19, 2018, 12:56 p.m.
Fix a build error:

cc1: warnings being treated as errors
.../gas/config/tc-ppc.c: In function 'ppc_dwsect':
.../gas/config/tc-ppc.c:4091: warning: comparison between signed and unsigned
make[4]: *** [config/tc-ppc.o] Error 1

observed with GCC 4.1.2 with the `powerpc-beos' target.

Here `flag' identifies the type of a DWARF section, as used with the the 
first operand to the `.dwsect' pseudo-op, and has no notion of a sign, 
or for that matter being arithmetic in the first place[1].  We already 
handle this correctly with the `flag' member of the `xcoff_dwsect_name' 
structure, however not in the local variable used in GAS to hold the 
parsed value of said `.dwsect' pseudo-op's operand.

Use an unsigned data type in GAS then too, observing that both `offsetT' 
and `valueT' have the same width, as they correspond to `bfd_signed_vma' 
and `bfd_vma' respectively.

References:

[1] "AIX Version 7.2: Assembler Language Reference", IBM Corporation 
    2015, 2018, Section ".dwsect pseudo-op", pp. 531-532

	gas/
	* config/tc-ppc.c (ppc_dwsect): Use `valueT' rather than 
	`offsetT' as the type of `flag'.
---
 gas/config/tc-ppc.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

binutils-ppc-gas-xcoff-dwsect-flag.diff

Comments

Alan Modra Sept. 19, 2018, 11:59 p.m. | #1
On Wed, Sep 19, 2018 at 01:56:07PM +0100, Maciej W. Rozycki wrote:
> 	* config/tc-ppc.c (ppc_dwsect): Use `valueT' rather than 

> 	`offsetT' as the type of `flag'.


OK.

-- 
Alan Modra
Australia Development Lab, IBM
Maciej W. Rozycki Sept. 20, 2018, 2:54 p.m. | #2
On Thu, 20 Sep 2018, Alan Modra wrote:

> > 	* config/tc-ppc.c (ppc_dwsect): Use `valueT' rather than 

> > 	`offsetT' as the type of `flag'.

> 

> OK.


 Applied, thanks for your review.

  Maciej

Patch

Index: src/gas/config/tc-ppc.c
===================================================================
--- src.orig/gas/config/tc-ppc.c
+++ src/gas/config/tc-ppc.c
@@ -4077,7 +4077,7 @@  ppc_change_debug_section (unsigned int i
 static void
 ppc_dwsect (int ignore ATTRIBUTE_UNUSED)
 {
-  offsetT flag;
+  valueT flag;
   symbolS *opt_label;
   const struct xcoff_dwsect_name *dw;
   struct dw_subsection *subseg;