From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16298 invoked by alias); 2 Dec 2002 12:57:24 -0000 Mailing-List: contact cgen-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sources.redhat.com Received: (qmail 16285 invoked from network); 2 Dec 2002 12:57:23 -0000 Received: from unknown (HELO mta02ps.bigpond.com) (144.135.25.134) by sources.redhat.com with SMTP; 2 Dec 2002 12:57:23 -0000 Received: from bubble.local ([144.135.25.81]) by mta02ps.bigpond.com (Netscape Messaging Server 4.15 mta02ps Jul 16 2002 22:47:55) with SMTP id H6HTBL00.B4U for ; Mon, 2 Dec 2002 22:57:21 +1000 Received: from CPE-144-136-184-243.sa.bigpond.net.au ([144.136.184.243]) by psmam05.mailsvc.email.bigpond.com(MailRouter V3.0n 107/20083946); 02 Dec 2002 22:57:21 Received: (qmail 30794 invoked by uid 179); 2 Dec 2002 12:57:20 -0000 Date: Mon, 02 Dec 2002 04:57:00 -0000 From: Alan Modra To: cgen@sources.redhat.com, binutils@sources.redhat.com Subject: Re: Fix cgen warnings in opcodes/ Message-ID: <20021202125720.GG27956@bubble.sa.bigpond.net.au> Mail-Followup-To: cgen@sources.redhat.com, binutils@sources.redhat.com References: <20021202065854.GE27956@bubble.sa.bigpond.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021202065854.GE27956@bubble.sa.bigpond.net.au> User-Agent: Mutt/1.4i X-SW-Source: 2002-q4/txt/msg00045.txt.bz2 On Mon, Dec 02, 2002 at 05:28:55PM +1030, Alan Modra wrote: > This patch > banishes most of the warnings in cgen files, leaving only a few about > unused functions/vars. Well, that was a rash claim. There were some type punned pointer warnings to fix in cgen/cpu/openrisc.opc, and lots of missing initializer warnings for opcodes/m32r-opinst.c, fixed by the opc-opinst.scm change. cgen/ChangeLog * opc-opinst.scm (-gen-operand-instance-table): Init all fields of structure when using END. * cpu/openrisc.opc (openrisc_sign_extend_16bit): Don't rely on "short" being 16 bit. (parse_hi16): Likewise. Fix type-punned pointer warnings too, and internationalize error message. (parse_lo16): Likewise. Remove useless code. Index: cgen/opc-opinst.scm =================================================================== RCS file: /cvs/src/src/cgen/opc-opinst.scm,v retrieving revision 1.2 diff -u -p -r1.2 opc-opinst.scm --- cgen/opc-opinst.scm 20 Nov 2000 19:03:33 -0000 1.2 +++ cgen/opc-opinst.scm 2 Dec 2002 12:40:46 -0000 @@ -54,7 +54,7 @@ ins) (string-map (lambda (op) (-gen-operand-instance op "OUTPUT")) outs) - " { END }\n};\n\n"))) + " { END, 0, 0, 0, 0, 0, 0 }\n};\n\n"))) ) (define (-gen-operand-instance-tables) Index: cgen/cpu/openrisc.opc =================================================================== RCS file: /cvs/src/src/cgen/cpu/openrisc.opc,v retrieving revision 1.2 diff -u -p -r1.2 openrisc.opc --- cgen/cpu/openrisc.opc 9 Oct 2001 08:24:22 -0000 1.2 +++ cgen/cpu/openrisc.opc 2 Dec 2002 12:53:26 -0000 @@ -44,7 +44,7 @@ long openrisc_sign_extend_16bit (value) long value; { - return (long) (short) value; + return ((value & 0xffff) ^ 0x8000) - 0x8000; } /* Handle hi(). */ @@ -58,15 +58,16 @@ parse_hi16 (cd, strp, opindex, valuep) { const char *errmsg; enum cgen_parse_operand_result result_type; - bfd_vma value; + unsigned long ret; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "hi(", 3) == 0) { - *strp += 3; + bfd_vma value; + *strp += 3; #if 0 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep); if (errmsg != NULL) @@ -76,23 +77,31 @@ parse_hi16 (cd, strp, opindex, valuep) errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, &result_type, &value); if (**strp != ')') - return "missing `)'"; + return _("missing `)'"); + ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value >>= 16; - *valuep = (long) (short) value; - - return errmsg; + ret = value; } else { if (**strp == '-') - errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value); + { + long value; + errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); + ret = value; + } else - errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value); + { + unsigned long value; + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); + ret = value; + } } - *valuep = (long) (short) (value & 0xffff); + + *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; return errmsg; } @@ -107,15 +116,16 @@ parse_lo16 (cd, strp, opindex, valuep) { const char *errmsg; enum cgen_parse_operand_result result_type; - bfd_vma value; + unsigned long ret; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "lo(", 3) == 0) { - *strp += 3; + bfd_vma value; + *strp += 3; #if 0 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep); if (errmsg != NULL) @@ -126,21 +136,28 @@ parse_lo16 (cd, strp, opindex, valuep) errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, &result_type, &value); if (**strp != ')') - return "missing `)'"; - ++*strp; - if (errmsg == NULL - && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) - value &= 0xffff; - *valuep = (long) (short) value; + return _("missing `)'"); - return errmsg; + ++*strp; + ret = value; } - - if (**strp == '-') - errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value); else - errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value); - *valuep = (long) (short) (value & 0xffff); + { + if (**strp == '-') + { + long value; + errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); + ret = value; + } + else + { + unsigned long value; + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); + ret = value; + } + } + + *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; return errmsg; } -- Alan Modra IBM OzLabs - Linux Technology Centre