From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: "'Daniel Jacobowitz'" <drow@false.org>
Cc: <gdb-patches@sourceware.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 [thread overview]
Message-ID: <003801c864a4$1866bee0$49343ca0$@u-strasbg.fr> (raw)
In-Reply-To: <20080131222641.GD6715@caradoc.them.org>
> -----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
next prev parent reply other threads:[~2008-02-01 7:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-28 17:08 Pierre Muller
2008-01-31 22:43 ` Daniel Jacobowitz
2008-02-01 7:29 ` Pierre Muller [this message]
2008-02-01 14:16 ` 'Daniel Jacobowitz'
2008-02-01 15:55 ` Pierre Muller
2008-02-01 17:00 ` Doug Evans
2008-02-01 17:04 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003801c864a4$1866bee0$49343ca0$@u-strasbg.fr' \
--to=muller@ics.u-strasbg.fr \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox