From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31122 invoked by alias); 1 Feb 2008 07:29:13 -0000 Received: (qmail 31114 invoked by uid 22791); 1 Feb 2008 07:29:12 -0000 X-Spam-Check-By: sourceware.org Received: from ics.u-strasbg.fr (HELO ics.u-strasbg.fr) (130.79.112.250) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 01 Feb 2008 07:28:53 +0000 Received: from ICSMULLER (unknown [130.79.244.147]) by ics.u-strasbg.fr (Postfix) with ESMTP id 263A118701F; Fri, 1 Feb 2008 08:35:11 +0100 (CET) From: "Pierre Muller" To: "'Daniel Jacobowitz'" Cc: References: <000c01c861c5$149352b0$3db9f810$@u-strasbg.fr> <20080131222641.GD6715@caradoc.them.org> In-Reply-To: <20080131222641.GD6715@caradoc.them.org> Subject: RE: [Patch] p-exp.y: Typecast left operand of BINOP_DIV to long double Date: Fri, 01 Feb 2008 07:29:00 -0000 Message-ID: <003801c864a4$1866bee0$49343ca0$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Content-Language: en-us Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00004.txt.bz2 > -----Original Message----- > From: Daniel Jacobowitz [mailto:drow@false.org] > Sent: Thursday, January 31, 2008 11:27 PM > To: Pierre Muller > Cc: gdb-patches@sourceware.org > Subject: Re: [Patch] p-exp.y: Typecast left operand of BINOP_DIV to > long double > > On Mon, Jan 28, 2008 at 04:47:26PM +0100, Pierre Muller wrote: > > Could someone please confirm that the > > way I inserted the implicit typecast in the parser is > > correct? > > All comments most welcome. > > It looks OK to me. Does the type of the left operand completely > determine the type of the operation, or do you need to worry about the > type of the right-hand exp too before you cast? But how can I do this? It is still not really clear to me how I can insert a typecast to left operand, only after right operand has been parsed. It would indeed be better to only do the typecast if both are integral types. > > @@ -367,7 +370,15 @@ exp : exp '*' exp > > { write_exp_elt_opcode (BINOP_MUL); } > > ; > > > > -exp : exp '/' exp > > +exp : exp '/' { > > + if (current_type && is_integral_type > > (current_type)) > > + { > > + write_exp_elt_opcode (UNOP_CAST); > > + write_exp_elt_type > (builtin_type_long_double); > > + write_exp_elt_opcode (UNOP_CAST); > > + } > > + } > > + exp > > { write_exp_elt_opcode (BINOP_DIV); } > > ; > > > > Won't current_type still be integral after this? Try 1 / 2 / 3. Whoops, of course, this lacks a current_type = builtin_type_long_double assignment. Thanks for the comments. Pierre