From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, Ulrich Weigand <uweigand@de.ibm.com>,
Jim Blandy <jimb@red-bean.com>, Tobias Burnus <burnus@net-b.de>
Subject: Re: [patch] (for VLA) Prepare for 3-fields TYPE_CODE_RANGE (TYPE_HIGH_BOUND)
Date: Sun, 28 Dec 2008 13:09:00 -0000 [thread overview]
Message-ID: <20081228130836.GD4216@adacore.com> (raw)
In-Reply-To: <20081226224219.GA3513@host0.dyn.jankratochvil.net>
> Questionable is whether ada_array_bound_from_type() can get something besides
> TYPE_CODE_RANGE or TYPE_CODE_ENUM which gets internal_error()ed now. I did
> not find such case but the TYPE_CODE_ENUM case could be changed to `default:'
> if it can happen.
Initially, I was thinking that maybe we could get a range type that's
a TYPE_CODE_INT. But that's not possible either with stabs nor DWARF.
But I think the code is fine as it is.
> 2008-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Fix TYPE_HIGH_BOUND for TYPE_CODE_RANGE using arbitrary TYPE_NFIELDS.
Perhaps you could mention that this is in preparation for supporting
DW_AT_byte_stride.
> * ada-lang.c (packed_array_type, ada_index_type): Use TYPE_INDEX_TYPE.
> (ada_array_bound_from_type): Move `index_type' declaration to the
> function start. Return the bounds for TYPE_CODE_RANGE using
> TYPE_LOW_BOUND and TYPE_HIGH_BOUND. Abort on invalid index type codes.
> * ada-typeprint.c (print_range): Set `upper_bound' for TYPE_CODE_RANGE
> now using TYPE_HIGH_BOUND.
> * ada-valprint.c (val_print_packed_array_elements): Use `index_type'.
> * eval.c (evaluate_subexp_standard): Use TYPE_INDEX_TYPE.
> * gdbtypes.c (create_range_type): Use TYPE_LOW_BOUND, TYPE_HIGH_BOUND,
> refer to the number of fields only through TYPE_NFIELDS.
> (create_array_type): Use TYPE_INDEX_TYPE.
> (check_typedef): Use TYPE_INDEX_TYPE, TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
> * gdbtypes.h (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
> (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED): Use TYPE_INDEX_TYPE.
> (TYPE_ARRAY_UPPER_BOUND_VALUE, TYPE_ARRAY_LOWER_BOUND_VALUE): Use
> TYPE_INDEX_TYPE, TYPE_LOW_BOUND, TYPE_HIGH_BOUND,
> * hppa-tdep.c (hppa_alignof <TYPE_CODE_ARRAY>): Use TYPE_INDEX_TYPE.
> * mdebugread.c (parse_type): Use TYPE_LOW_BOUND, TYPE_HIGH_BOUND,
> * valarith.c (value_bit_index): Use TYPE_INDEX_TYPE.
OK. Please just make a tiny change before checking in.
(in ada_array_bound_from_type):
> + if (typep != NULL)
> + *typep = index_type;
>
> - return
> - (LONGEST) (which == 0
> - ? TYPE_LOW_BOUND (index_type)
> - : TYPE_HIGH_BOUND (index_type));
> + switch (TYPE_CODE (index_type))
> + {
> + case TYPE_CODE_RANGE:
> + return which == 0 ? TYPE_LOW_BOUND (index_type)
> + : TYPE_HIGH_BOUND (index_type);
> + case TYPE_CODE_ENUM:
> + return which == 0 ? TYPE_FIELD_BITPOS (index_type, 0)
> + : TYPE_FIELD_BITPOS (index_type,
> + TYPE_NFIELDS (index_type) - 1);
> + default:
> + internal_error (__FILE__, __LINE__, _("invalid type code of index type"));
> }
If we raise the internal_error, I'd rather we do no assign *typep.
Can you instead compute the bound value first, and then, if we haven't
detected the internal error, assign *typep before returning the bound?
Thanks,
--
Joel
next prev parent reply other threads:[~2008-12-28 13:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-26 22:43 Jan Kratochvil
2008-12-28 13:09 ` Joel Brobecker [this message]
2008-12-28 14:18 ` Jan Kratochvil
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=20081228130836.GD4216@adacore.com \
--to=brobecker@adacore.com \
--cc=burnus@net-b.de \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=jimb@red-bean.com \
--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