From: Joel Brobecker <brobecker@adacore.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
Date: Tue, 09 Sep 2008 18:00:00 -0000 [thread overview]
Message-ID: <20080909175934.GE12222@adacore.com> (raw)
In-Reply-To: <200809071542.m87FgUGp031738@d12av02.megacenter.de.ibm.com>
> > > two more small changes to ada-lang.c: ada_array_length would
> > > simply use builtin_type_int as type of its return value, even
> > > though it should probably better use the type of the array bounds.
> >
> > I don't think this part is correct, since the bounds can be any discrete
> > type, which includes enumeration types. The 'Length attribute is defined
> > as returning a universal_integer. The definition of universal_integer
> > is a little complicated for me, but it is an integer.
>
> I see; it seems I have misinterpreted range types -- I though they
> were always based on an integer type.
A range type is, I think, always based on an integer type. But the
thing is that array index types can be any discrete type: This means
that one can use an enumerated type as well.
So, for ada_array_length, shall use use a type of builtin_type_int32?
That's what I did for my testing (more on this in a separate message)
> > > case TYPE_CODE_RANGE:
> > > - arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> > > - arg3 = value_from_longest (builtin_type_int,
> > > - TYPE_HIGH_BOUND (type));
> > > + arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > + TYPE_LOW_BOUND (type));
> > > + arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > + TYPE_HIGH_BOUND (type));
> > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
> > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
> > > type = language_bool_type (exp->language_defn, exp->gdbarch);
> >
> > I don't really understand why the TYPE_TARGET_TYPE is necessarily
> > an integer type. I don't even think that the TYPE_TARGET_TYPE
> > is necessarily set, particularly in the case of enumerated types
> > or base types.
> >
> > We have access to the int type through the expression in this case.
> > Can we use that?
>
> I guess so, but it would appear this doesn't really help. There isn't
> really anything in the language that says the gdbarch's int type is the
> "correct" type to use here, or is there?
No, I don't think so. I had a look at the Ada Reference Manual,
and it doesn't say anything about that.
> If not, and this is just about using some "random" integer type to perform
> the comparison in, it seems to me using builtin_type_int32 here as well
> would be better ...
It just occured to me that, since this is a TYPE_CODE_RANGE, can't
we just use its type? A TYPE_CODE_RANGE should always be some kind
of "integer" type, so why not use that when calling value_from_longest?
I have this awful feeling that we're missing something, but I don't
see what. Do you see anything wrong with that?
--
Joel
next prev parent reply other threads:[~2008-09-09 18:00 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
2008-09-06 3:15 ` Joel Brobecker
2008-09-07 16:44 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture uweigand
2008-08-31 17:52 ` [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator uweigand
2008-08-31 17:52 ` [rfc][33/37] Eliminate builtin_type_ macros: Default target word size uweigand
2008-08-31 17:52 ` [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
2008-08-31 17:52 ` [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc uweigand
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
2008-09-05 23:13 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
2008-09-05 18:08 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
2008-09-06 0:24 ` Joel Brobecker
2008-09-07 15:43 ` Ulrich Weigand
2008-09-09 18:00 ` Joel Brobecker [this message]
2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 22:08 ` Joel Brobecker
2008-09-09 22:32 ` Ulrich Weigand
2008-09-10 6:09 ` Joel Brobecker
2008-09-10 9:51 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture uweigand
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
2008-09-05 22:56 ` Joel Brobecker
2008-09-07 15:40 ` Ulrich Weigand
2008-09-07 15:49 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
2008-09-01 7:19 ` Tom Tromey
2008-09-02 23:34 ` Ulrich Weigand
2008-09-05 23:02 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
2008-09-05 18:18 ` Joel Brobecker
2008-09-05 20:16 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit uweigand
2008-08-31 17:52 ` [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines uweigand
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
2008-09-06 0:38 ` Joel Brobecker
2008-09-06 4:12 ` Daniel Jacobowitz
2008-09-06 14:00 ` Joel Brobecker
2008-09-07 15:59 ` Ulrich Weigand
2008-09-13 15:23 ` Daniel Jacobowitz
2008-09-13 17:23 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
2008-09-02 12:43 ` Daniel Jacobowitz
2008-09-02 21:55 ` Ulrich Weigand
2008-09-02 22:00 ` Daniel Jacobowitz
2008-09-02 23:53 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling uweigand
2008-08-31 17:53 ` [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references uweigand
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
2008-09-05 18:16 ` Joel Brobecker
2008-09-05 20:17 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros uweigand
2008-08-31 17:53 ` [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit uweigand
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
2008-09-05 20:18 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
2008-09-05 22:39 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
2008-09-02 12:38 ` Daniel Jacobowitz
2008-09-02 21:48 ` Ulrich Weigand
2008-09-02 21:52 ` Daniel Jacobowitz
2008-09-04 22:32 ` Tom Tromey
2008-09-05 18:21 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info uweigand
2008-08-31 17:53 ` [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c uweigand
2008-08-31 17:53 ` [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation uweigand
2008-08-31 17:53 ` [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types uweigand
2008-08-31 17:53 ` [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code uweigand
2008-08-31 17:53 ` [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number uweigand
2008-08-31 17:53 ` [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type uweigand
2008-08-31 18:12 ` [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c uweigand
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
2008-09-06 1:37 ` Joel Brobecker
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
2008-09-02 12:48 ` Daniel Jacobowitz
2008-09-02 21:56 ` Ulrich Weigand
2008-08-31 18:16 ` [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files uweigand
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
2008-09-01 3:46 ` David Miller
2008-09-01 18:57 ` Ulrich Weigand
2008-09-02 10:22 ` Mark Kettenis
2008-09-02 12:30 ` Daniel Jacobowitz
2008-09-02 21:37 ` Ulrich Weigand
2008-09-02 12:50 ` Daniel Jacobowitz
2008-09-02 22:02 ` Ulrich Weigand
2008-09-02 22:12 ` Daniel Jacobowitz
2008-09-06 3:16 ` Joel Brobecker
2008-09-07 16:43 ` Ulrich Weigand
2008-09-09 18:05 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 21:18 ` Joel Brobecker
2008-09-09 22:12 ` Ulrich Weigand
2008-09-10 6:18 ` Joel Brobecker
2008-09-10 9:43 ` Ulrich Weigand
2008-09-10 16:25 ` Joel Brobecker
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=20080909175934.GE12222@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.com \
/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