From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23336 invoked by alias); 17 Jun 2005 03:13:03 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23298 invoked by uid 22791); 17 Jun 2005 03:12:57 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 17 Jun 2005 03:12:57 +0000 Received: from drow by nevyn.them.org with local (Exim 4.51) id 1Dj7Hr-0001gL-AF; Thu, 16 Jun 2005 23:12:55 -0400 Date: Fri, 17 Jun 2005 03:13:00 -0000 From: Daniel Jacobowitz To: Ralf Corsepius Cc: GDB Patches Subject: Re: [PATCH,sim/sh] lvalue casts Message-ID: <20050617031255.GE17013@nevyn.them.org> Mail-Followup-To: Ralf Corsepius , GDB Patches References: <1115047102.24385.376.camel@mccallum.corsepiu.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1115047102.24385.376.camel@mccallum.corsepiu.local> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-06/txt/msg00236.txt.bz2 On Mon, May 02, 2005 at 05:18:22PM +0200, Ralf Corsepius wrote: > Hi, > > gcc-4.0.0 chokes on with an "invalid lvalue" error on the code generated > by sh/gencode.c (gdb-CVS mainline). > > The patch below seems to fix this issue for me. > > AFAIS, the "(unsigned int) R[]" cast are just superfluous. Sorry about the delay. > 2005-05-02 Ralf Corsepius > > * gencode.c (divu R0,): Remove lvalue casts to please gcc4. > > > Index: gencode.c > =================================================================== > RCS file: /cvs/src/src/sim/sh/gencode.c,v > retrieving revision 1.31 > diff -u -r1.31 gencode.c > --- gencode.c 14 Apr 2005 20:16:06 -0000 1.31 > +++ gencode.c 2 May 2005 15:10:03 -0000 > @@ -215,7 +215,7 @@ > "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();", > "if (R0 == 0)", > " R[n] = 0xffffffff;", > - "else (unsigned int) R[n] = (unsigned int) R[n] / (unsigned int) R0;", > + "else R[n] = R[n] / (unsigned int) R0;", > "L (n);", > }, The second cast definitely can go; int will be promoted to unsigned int automatically, and that's a well defined conversion. However, the other half is dodgier: [#3] Otherwise, the new type is signed and the value cannot be represented in it; either the result is implementation- defined or an implementation-defined signal is raised. So for 0xffffffff / 1u, the result is implementation-defined. Unfortunate. We'll just have to propogate the assumption that the implementation uses the sensible definition... I've committed the below. Now I can build GDB for sh-elf using gcc 4.0, though not with -Werror yet. -- Daniel Jacobowitz CodeSourcery, LLC 2005-06-16 Daniel Jacobowitz * gencode.c (tab): Avoid lvalue casts. Suggested by Ralf Corsepius . Index: gencode.c =================================================================== RCS file: /cvs/src/src/sim/sh/gencode.c,v retrieving revision 1.31 diff -u -p -r1.31 gencode.c --- gencode.c 14 Apr 2005 20:16:06 -0000 1.31 +++ gencode.c 17 Jun 2005 03:06:38 -0000 @@ -215,7 +215,9 @@ op tab[] = "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();", "if (R0 == 0)", " R[n] = 0xffffffff;", - "else (unsigned int) R[n] = (unsigned int) R[n] / (unsigned int) R0;", + "/* FIXME: The result may be implementation-defined if it is outside */", + "/* the range of signed int (i.e. if R[n] was negative and R0 == 1). */", + "else R[n] = R[n] / (unsigned int) R0;", "L (n);", }, { "n", "0n", "mulr R0,", "0100nnnn10000000",