From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: drow@false.org (Daniel Jacobowitz)
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Use LONGEST instead of value for index arithmetic
Date: Fri, 26 Jun 2009 16:50:00 -0000 [thread overview]
Message-ID: <200906261650.n5QGo406008337@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <20090626160033.GA16047@caradoc.them.org> from "Daniel Jacobowitz" at Jun 26, 2009 12:00:33 PM
Daniel Jacobowitz wrote:
> On Fri, Jun 26, 2009 at 05:49:07PM +0200, Ulrich Weigand wrote:
> > Hello,
> >
> > this patch implements the change I mentioned recently: use LONGEST instead
> > of struct value to represent array indexes (and similarly the integer
> > operands to pointer arithmetic). This has the advantage that index
> > computations can be performed in host instead of target arithmetic,
> > and not just eliminates a bunch of references to global built-in types,
> > but makes both implementation and users of the value_subscript and
> > pointer arithmetic routines quite a bit simpler.
>
> Looks good to me. I noticed you're removing several error calls; do
> those garbage cases still produce some error message? I guess they
> must be untested :-(
All error messages should be preserved by my changes, but I admit this
isn't quite obvious. For example, in the "pointer + not-integer" case,
the following error used to be emitted by value_ptradd:
- if (!is_integral_type (value_type (arg2)))
- error (_("Argument to arithmetic operation not a number or boolean."));
With the patch applied, due to those eval.c changes:
- else if (ptrmath_type_p (value_type (arg1)))
- return value_ptradd (arg1, arg2);
- else if (ptrmath_type_p (value_type (arg2)))
- return value_ptradd (arg2, arg1);
+ else if (ptrmath_type_p (value_type (arg1))
+ && is_integral_type (value_type (arg2)))
+ return value_ptradd (arg1, value_as_long (arg2));
+ else if (ptrmath_type_p (value_type (arg2))
+ && is_integral_type (value_type (arg1)))
+ return value_ptradd (arg2, value_as_long (arg1));
else
{
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
control will fall through to the default value_binop code, and *this*
will now issue the error message:
if ((TYPE_CODE (type1) != TYPE_CODE_FLT
&& TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
&& !is_integral_type (type1))
|| (TYPE_CODE (type2) != TYPE_CODE_FLT
&& TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
&& !is_integral_type (type2)))
error (_("Argument to arithmetic operation not a number or boolean."));
(Note that when I originally introduced value_ptradd I duplicated this
message in the first place.)
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2009-06-26 16:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-26 15:49 Ulrich Weigand
2009-06-26 16:00 ` Daniel Jacobowitz
2009-06-26 16:50 ` Ulrich Weigand [this message]
2009-06-26 18:21 ` Daniel Jacobowitz
2009-06-29 13:26 ` Ulrich Weigand
2009-06-26 16:40 ` Tom Tromey
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=200906261650.n5QGo406008337@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--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