From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6Hv4HJLSwl8DdQAAWB0awg (envelope-from ) for ; Sat, 28 Nov 2020 17:43:30 -0500 Received: by simark.ca (Postfix, from userid 112) id 6B5491F0AB; Sat, 28 Nov 2020 17:43:30 -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.4 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 C146F1E590 for ; Sat, 28 Nov 2020 17:43:29 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61866386F41A; Sat, 28 Nov 2020 22:43:29 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.145.216]) by sourceware.org (Postfix) with ESMTPS id DED073857C4C for ; Sat, 28 Nov 2020 22:43:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DED073857C4C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 58E19C830 for ; Sat, 28 Nov 2020 16:43:25 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j8w9kvS90fAtaj8w9klAwq; Sat, 28 Nov 2020 16:43:25 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5L0OIsFACOhZRk2/5h7Vp29q5UDCg6FfKdHVWkTac5U=; b=KoHKMXmL8FqakTk8vG8KVK+j36 RqdBYDIDqHEctfR0fVkB89sj9tKPfyTBfDPMOhmcoDQXXYZpRObIBib2ftSRii7f0mFXAmt1RRz2V MX/IeUyItw0aCrW/X0DVP0oSb; Received: from 97-122-89-243.hlrn.qwest.net ([97.122.89.243]:36904 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kj8w9-000TUF-1R; Sat, 28 Nov 2020 15:43:25 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH] Remove some dead code from evaluate_subexp_standard Date: Sat, 28 Nov 2020 15:43:23 -0700 Message-Id: <20201128224323.15882-1-tom@tromey.com> X-Mailer: git-send-email 2.17.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.89.243 X-Source-L: No X-Exim-ID: 1kj8w9-000TUF-1R X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-89-243.hlrn.qwest.net (bapiya.Home) [97.122.89.243]:36904 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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. 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