From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23595 invoked by alias); 31 Aug 2008 17:52:24 -0000 Received: (qmail 23218 invoked by uid 22791); 31 Aug 2008 17:52:17 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:51:31 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpRxT111184 for ; Sun, 31 Aug 2008 17:51:28 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.0) with ESMTP id m7VHpSfY1683462 for ; Sun, 31 Aug 2008 19:51:28 +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 m7VHpSmk020128 for ; Sun, 31 Aug 2008 19:51:28 +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 ESMTP id m7VHpSnL020123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:28 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (localhost.localdomain [127.0.0.1]) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpRwh002707 for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpR68002706 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:27 +0200 Message-Id: <20080831175127.749914000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:53:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type Content-Disposition: inline; filename=diff-type-adapos 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-08/txt/msg00694.txt.bz2 Hello, the value_pos_atr uses a hard-coded builtin_type_int as the type of its result value. This patch adds a TYPE parameter instead and pushes the choice of result type up to the callers. Bye, Ulrich ChangeLog: * ada-lang.c (value_pos_atr): Add TYPE argument. Use it as result type instead of builtin_type_int. (value_subscript_packed): Use pos_atr instead of value_pos_atr. (ada_value_subscript): Update call to value_pos_atr. (ada_value_ptr_subscript): Likewise. (ada_evaluate_subexp): Likewise. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -212,7 +212,7 @@ static struct value *ada_coerce_ref (str static LONGEST pos_atr (struct value *); -static struct value *value_pos_atr (struct value *); +static struct value *value_pos_atr (struct type *, struct value *); static struct value *value_val_atr (struct type *, struct value *); @@ -1968,7 +1968,7 @@ value_subscript_packed (struct value *ar lowerbound = upperbound = 0; } - idx = value_as_long (value_pos_atr (ind[i])); + idx = pos_atr (ind[i]); if (idx < lowerbound || idx > upperbound) lim_warning (_("packed array index %ld out of bounds"), (long) idx); bits = TYPE_FIELD_BITSIZE (elt_type, 0); @@ -2344,7 +2344,7 @@ ada_value_subscript (struct value *arr, { if (TYPE_CODE (elt_type) != TYPE_CODE_ARRAY) error (_("too many subscripts (%d expected)"), k); - elt = value_subscript (elt, value_pos_atr (ind[k])); + elt = value_subscript (elt, value_pos_atr (builtin_type_int32, ind[k])); } return elt; } @@ -2369,7 +2369,7 @@ ada_value_ptr_subscript (struct value *a arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), value_copy (arr)); get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb); - idx = value_pos_atr (ind[k]); + idx = value_pos_atr (builtin_type_int32, ind[k]); if (lwb != 0) idx = value_binop (idx, value_from_longest (value_type (idx), lwb), BINOP_SUB); @@ -7660,9 +7660,9 @@ pos_atr (struct value *arg) } static struct value * -value_pos_atr (struct value *arg) +value_pos_atr (struct type *type, struct value *arg) { - return value_from_longest (builtin_type_int, pos_atr (arg)); + return value_from_longest (type, pos_atr (arg)); } /* Evaluate the TYPE'VAL attribute applied to ARG. */ @@ -9101,19 +9101,21 @@ ada_evaluate_subexp (struct type *expect arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type_int, not_lval); + type = builtin_type (exp->gdbarch)->builtin_int; + if (noside == EVAL_AVOID_SIDE_EFFECTS) + return value_zero (type, not_lval); else - return value_pos_atr (arg1); + return value_pos_atr (type, arg1); case OP_ATR_SIZE: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type_int, not_lval); + type = builtin_type (exp->gdbarch)->builtin_int; + if (noside == EVAL_AVOID_SIDE_EFFECTS) + return value_zero (type, not_lval); else - return value_from_longest (builtin_type_int, + return value_from_longest (type, TARGET_CHAR_BIT * TYPE_LENGTH (value_type (arg1))); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com