From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5249 invoked by alias); 26 Jun 2009 16:50:14 -0000 Received: (qmail 5237 invoked by uid 22791); 26 Jun 2009 16:50:13 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS 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.43rc1) with ESMTP; Fri, 26 Jun 2009 16:50:08 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.14.3/8.13.8) with ESMTP id n5QGo5nD348710 for ; Fri, 26 Jun 2009 16:50:05 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.2) with ESMTP id n5QGo5DH3866874 for ; Fri, 26 Jun 2009 18:50:05 +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 n5QGo5oq008369 for ; Fri, 26 Jun 2009 18:50:05 +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 n5QGo406008337; Fri, 26 Jun 2009 18:50:04 +0200 Message-Id: <200906261650.n5QGo406008337@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 26 Jun 2009 18:50:04 +0200 Subject: Re: [rfc] Use LONGEST instead of value for index arithmetic To: drow@false.org (Daniel Jacobowitz) Date: Fri, 26 Jun 2009 16:50:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <20090626160033.GA16047@caradoc.them.org> from "Daniel Jacobowitz" at Jun 26, 2009 12:00:33 PM 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: 2009-06/txt/msg00743.txt.bz2 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