From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id VCeBG8X8w19qEAAAWB0awg (envelope-from ) for ; Sun, 29 Nov 2020 14:55:49 -0500 Received: by simark.ca (Postfix, from userid 112) id 6577C1F0AB; Sun, 29 Nov 2020 14:55:49 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0F3BF1E58E for ; Sun, 29 Nov 2020 14:55:49 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFBCC3850404; Sun, 29 Nov 2020 19:55:48 +0000 (GMT) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 9948F385ED4B for ; Sun, 29 Nov 2020 19:55:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9948F385ED4B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x42e.google.com with SMTP id 23so12465608wrc.8 for ; Sun, 29 Nov 2020 11:55:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=q3oIRiS75dXoXc3DWODHvyAS4FoVngBsvjulzxdGaso=; b=BVcp++7ZfFcpBaDsrzWHGMVVHbQ+PU6a9ZslMlf2o30MhyPgS6SHUHAZOU1oSY09Lx kP0a5VEL0LL8cxq7OAy5hru3/gtgTEaoYomQ/bNNBQtAXSGgbFIC3aKbAfuPRPKC0daO ZW/Qlekhkxxp6RY2BZsMXFEkyiCxzXrJVcOiENQYLm5pB/8AVvV1Rs8mDe7McD787UTh 7QE+zA2yrpmYHOfpZunHKA2C1UpGNmNyTrE1Z0KjjDoOLSSmcm17SgRdbIW7oF9iutFx SUfJQuDb43VssT3WZCla93LwGh30EjqFfqkcqgBlINPUBZ7N/R7W8M6U/36YAv4PY1Xs P28w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=q3oIRiS75dXoXc3DWODHvyAS4FoVngBsvjulzxdGaso=; b=f3FRODyrizCvWbCI9Nm+CSq7BWAcW5eB4cCXYWC5K9FsPwugKWzx4u+OETt4LW0uSI daNHL3J7TgSAeF9SIyVoWqxT+PZk+VvwNqpHZgcUhI81BpK7X4/l6VRf6sT1Yu+7uUXr dI4NWqGlviEDGroe/mRemFdtqeMsl+9hlJJfcl8pBMT9PzLAd5ttrFL3JBIA7qBepK4+ M7QHAi6DlWTFmGX8+u5GRqTr6LW4PpJFDtJH8NTDtfrIs9wwyKtDix9NN0E+QyVZBMj5 LrrDADyEFFx4W+YWqvoVSgBPGDukC4wgrp/c+ZZAu0Qeo2WYWAgGLCamt5n0c5dQ+ysI 4CYQ== X-Gm-Message-State: AOAM532sOIwhrAue4y5yc6lvkO0DKg/FaIZQcOwSPtg73pCdPQH31hZ9 ydS3/YxHoQ3CWv5irzAdUjCyyg== X-Google-Smtp-Source: ABdhPJyzKQQOM1XKqRbRNnGaBDnqi0iN/EvLWGwT40ZValy4EBxdwp20GstYPD0OcGo156GtWZF+tg== X-Received: by 2002:a5d:62cb:: with SMTP id o11mr24436595wrv.25.1606679744753; Sun, 29 Nov 2020 11:55:44 -0800 (PST) Received: from localhost (host109-154-20-215.range109-154.btcentralplus.com. [109.154.20.215]) by smtp.gmail.com with ESMTPSA id r82sm2619097wma.18.2020.11.29.11.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 11:55:44 -0800 (PST) Date: Sun, 29 Nov 2020 19:55:43 +0000 From: Andrew Burgess To: Tom Tromey Subject: Re: [PATCH] Remove some dead code from evaluate_subexp_standard Message-ID: <20201129195543.GA2729@embecosm.com> References: <20201128224323.15882-1-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201128224323.15882-1-tom@tromey.com> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 19:47:02 up 35 days, 10:50, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * Tom Tromey [2020-11-28 15:43:23 -0700]: > I noticed that in the OP_ARRAY case in evaluate_subexp_standard, > "index_pc" is read but never set. This dead code then guards the only > call to init_array_element, so this can be removed as well. For the record index_pc was made redundant in commit: commit ae8fddda32d161ea0d8606fdd71349230d5b0ad6 Date: Tue Apr 15 11:28:15 2014 +0800 Remove operator BINOP_RANGE This change looks good to me, we've clearly not needed this functionality for the last 6 years! Thanks, Andrew > > gdb/ChangeLog > 2020-11-28 Tom Tromey > > * eval.c (init_array_element): Remove. > (evaluate_subexp_standard) : Remove "index_pc". > --- > gdb/ChangeLog | 5 ++++ > gdb/eval.c | 64 ++++++--------------------------------------------- > 2 files changed, 12 insertions(+), 57 deletions(-) > > diff --git a/gdb/eval.c b/gdb/eval.c > index 407d4b4ac59..d02813eec52 100644 > --- a/gdb/eval.c > +++ b/gdb/eval.c > @@ -57,10 +57,6 @@ static struct value *evaluate_struct_tuple (struct value *, > struct expression *, int *, > enum noside, int); > > -static LONGEST init_array_element (struct value *, struct value *, > - struct expression *, int *, enum noside, > - LONGEST, LONGEST); > - > struct value * > evaluate_subexp (struct type *expect_type, struct expression *exp, > int *pos, enum noside noside) > @@ -337,39 +333,6 @@ evaluate_struct_tuple (struct value *struct_val, > return struct_val; > } > > -/* Recursive helper function for setting elements of array tuples. > - The target is ARRAY (which has bounds LOW_BOUND to HIGH_BOUND); the > - element value is ELEMENT; EXP, POS and NOSIDE are as usual. > - Evaluates index expressions and sets the specified element(s) of > - ARRAY to ELEMENT. Returns last index value. */ > - > -static LONGEST > -init_array_element (struct value *array, struct value *element, > - struct expression *exp, int *pos, > - enum noside noside, LONGEST low_bound, LONGEST high_bound) > -{ > - LONGEST index; > - int element_size = TYPE_LENGTH (value_type (element)); > - > - if (exp->elts[*pos].opcode == BINOP_COMMA) > - { > - (*pos)++; > - init_array_element (array, element, exp, pos, noside, > - low_bound, high_bound); > - return init_array_element (array, element, > - exp, pos, noside, low_bound, high_bound); > - } > - else > - { > - index = value_as_long (evaluate_subexp (nullptr, exp, pos, noside)); > - if (index < low_bound || index > high_bound) > - error (_("tuple index out of range")); > - memcpy (value_contents_raw (array) + (index - low_bound) * element_size, > - value_contents (element), element_size); > - } > - return index; > -} > - > /* Promote value ARG1 as appropriate before performing a unary operation > on this argument. > If the result is not appropriate for any particular language then it > @@ -1433,30 +1396,17 @@ evaluate_subexp_standard (struct type *expect_type, > for (tem = nargs; --nargs >= 0;) > { > struct value *element; > - int index_pc = 0; > > element = evaluate_subexp (element_type, exp, pos, noside); > if (value_type (element) != element_type) > element = value_cast (element_type, element); > - if (index_pc) > - { > - int continue_pc = *pos; > - > - *pos = index_pc; > - index = init_array_element (array, element, exp, pos, noside, > - low_bound, high_bound); > - *pos = continue_pc; > - } > - else > - { > - if (index > high_bound) > - /* To avoid memory corruption. */ > - error (_("Too many array elements")); > - memcpy (value_contents_raw (array) > - + (index - low_bound) * element_size, > - value_contents (element), > - element_size); > - } > + if (index > high_bound) > + /* To avoid memory corruption. */ > + error (_("Too many array elements")); > + memcpy (value_contents_raw (array) > + + (index - low_bound) * element_size, > + value_contents (element), > + element_size); > index++; > } > return array; > -- > 2.17.2 >