From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2034 invoked by alias); 9 Sep 2008 22:32:19 -0000 Received: (qmail 2015 invoked by uid 22791); 9 Sep 2008 22:32:16 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate6.de.ibm.com (HELO mtagate6.de.ibm.com) (195.212.29.155) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 09 Sep 2008 22:31:33 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate6.de.ibm.com (8.13.8/8.13.8) with ESMTP id m89MUOxO330394 for ; Tue, 9 Sep 2008 22:30:24 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m89MUOAZ4321394 for ; Wed, 10 Sep 2008 00:30:24 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m89MUKNS000557 for ; Wed, 10 Sep 2008 00:30:21 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id m89MUKcR000554; Wed, 10 Sep 2008 00:30:20 +0200 Message-Id: <200809092230.m89MUKcR000554@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Wed, 10 Sep 2008 00:30:20 +0200 Subject: Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling To: brobecker@adacore.com (Joel Brobecker) Date: Tue, 09 Sep 2008 22:32:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <20080909220747.GJ12222@adacore.com> from "Joel Brobecker" at Sep 09, 2008 03:07:47 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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-09/txt/msg00202.txt.bz2 Joel Brobecker wrote: > First, I need to correct myself - ranges are not just for integral > types. You can have a range over any discrete type, which means > things like this: > > type Digit is (Zero, One, Two, ...); > subtype Binary is Digit range (Zero .. One); > > In this case, Binary would be defined as a subrange of the enumeration > type. However, after thinking about it awhile, I don't think that > enumeration types are that different from integral types in terms > of comparison and range check. Yes, value_less etc. should be able to handle enumeration (and range) types fine. > That being said: > > > Well, the only effect going through GDB values to perform the > > comparison has is to do the appropriate type promotions. However, if > > this doesn't actually apply for Ada, I'm wondering why we don't simply > > do the comparison on integral LONGEST values directly, like in the > > patch below? > > The only problem that I see is when the base type of the range type > is unsigned. value_less is supposed to be able to handle such cases, > whereas converting the bounds to a LONGEST might cause some problems, > no? I see. We'd need to compare either LONGEST or ULONGEST to take care of signed vs. unsigned types. value_less already does this ... So I guess your original proposal to use the range type itself is the simplest solution. Implemented by the patch below. Bye, Ulrich ChangeLog: * ada-lang.c (ada_array_length): Use builtin_type_int32 instead of builtin_type_int. (ada_evaluate_subexp) [UNOP_IN_RANGE]: Use operand range type instead of builtin_type_int. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -2623,7 +2623,7 @@ ada_array_length (struct value *arr, int } else return - value_from_longest (builtin_type_int, + value_from_longest (builtin_type_int32, value_as_long (desc_one_bound (desc_bounds (arr), n, 1)) - value_as_long (desc_one_bound (desc_bounds (arr), @@ -8860,9 +8860,8 @@ ada_evaluate_subexp (struct type *expect return value_from_longest (type, (LONGEST) 1); 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, TYPE_LOW_BOUND (type)); + arg3 = value_from_longest (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); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com