From patchwork Thu Jun 29 19:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 71858 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 965D63858408 for ; Thu, 29 Jun 2023 19:45:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 965D63858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688067926; bh=NcszqMs6vuDpCRns2kSkC9P3AIXleelGPVpje5Ujbno=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ojBF4RUZsSlx+auFv/OjRmjrgKmc9J9QUTH5SvvHxlMvEiwSaux3RfV2hkvq8ABMY 9vMejCMl5Py4I/wKKiunrsY403/dMO0sA19SuNpDjFGh3pIfgx8bbYUjz4STa4QbTe 8Y92rvsVrU47RAy+N1RdTwK2TKv9Jm2n56MkMAPs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id 75E043858D37 for ; Thu, 29 Jun 2023 19:44:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75E043858D37 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-78362f57500so47685939f.3 for ; Thu, 29 Jun 2023 12:44:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688067872; x=1690659872; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NcszqMs6vuDpCRns2kSkC9P3AIXleelGPVpje5Ujbno=; b=MlcnPmVj1J+Z3uKKrnw22dSo1AgYZudrd6XH2Fr+1LfxAwzRYuGxuZA7hG7xWr6LxF SYL4p1Lhlq3Nmr2U2tv9hv7uc4+kpvG7SOjWaJ4nIHmtq6Ss6T48cF+KPiCQ3E1RmwLk WJrEfDSOigMDUA/SI1n/VMErF2HrhMm91ux+/FZXYN7cROyBD8kzO2cmHkH2iflCpFKP PIlEDMrZxib/23S/M9D7KDmb1eWhK9AShJOZmqpLet9SJOdouDUpwVsOHTTFr/SO93z1 0sV7L5RLKrgXxWK2mdMxTSZs9gblk1/dRE9+Ixm5Y5arxvV8RUy+awP5tbjPAWmmmpsN N/oQ== X-Gm-Message-State: AC+VfDzSspHW3hnZY1gHtXx9rd5kX19Mn+i7VxwdXscqeXZ/YHpJQDnB YBb7viS0LP+cx+MIvfZ2MyrATMFg8WAGRJaLVkO7lQ== X-Google-Smtp-Source: ACHHUZ7bi0mN1DM9S/DKe7LjLoQcCU8cxgD+J9BekL7OQfg0vWkH6x6w3W0Nk+yuGyIr+pCbzXw78g== X-Received: by 2002:a6b:a0b:0:b0:783:58d1:823a with SMTP id z11-20020a6b0a0b000000b0078358d1823amr578552ioi.9.1688067872744; Thu, 29 Jun 2023 12:44:32 -0700 (PDT) Received: from localhost.localdomain (71-211-136-248.hlrn.qwest.net. [71.211.136.248]) by smtp.gmail.com with ESMTPSA id a16-20020a02ac10000000b0041cd626ea0csm2180768jao.147.2023.06.29.12.44.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 12:44:32 -0700 (PDT) Date: Thu, 29 Jun 2023 13:44:30 -0600 Subject: [PATCH 1/2] Remove ada_attribute_name MIME-Version: 1.0 Message-Id: <20230629-enum-attrs-v1-1-ee36873534e2@adacore.com> References: <20230629-enum-attrs-v1-0-ee36873534e2@adacore.com> In-Reply-To: <20230629-enum-attrs-v1-0-ee36873534e2@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" ada_attribute_name uses an array that must be kept in sync with an enum -- but the comment here refers to an enum that no longer exists. Looking at the sole caller, I see this can only be called for two opcodes. So, remove this entirely and inline it. --- gdb/ada-lang.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8e506bd4f2b..3d629cc110f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8767,35 +8767,6 @@ ada_to_fixed_value (struct value *val) /* Attributes */ -/* Table mapping attribute numbers to names. - NOTE: Keep up to date with enum ada_attribute definition in ada-lang.h. */ - -static const char * const attribute_names[] = { - "", - - "first", - "last", - "length", - "image", - "max", - "min", - "modulus", - "pos", - "size", - "tag", - "val", - 0 -}; - -static const char * -ada_attribute_name (enum exp_opcode n) -{ - if (n >= OP_ATR_FIRST && n <= (int) OP_ATR_VAL) - return attribute_names[n - OP_ATR_FIRST + 1]; - else - return attribute_names[0]; -} - /* Evaluate the 'POS attribute applied to ARG. */ static LONGEST @@ -10271,6 +10242,12 @@ static value * ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct type *type_arg, int tem) { + const char *attr_name = nullptr; + if (op == OP_ATR_FIRST) + attr_name = "first"; + else if (op == OP_ATR_LAST) + attr_name = "last"; + if (noside == EVAL_AVOID_SIDE_EFFECTS) { if (type_arg == NULL) @@ -10288,7 +10265,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, case OP_ATR_FIRST: case OP_ATR_LAST: type_arg = ada_index_type (type_arg, tem, - ada_attribute_name (op)); + attr_name); break; case OP_ATR_LENGTH: type_arg = builtin_type (exp->gdbarch)->builtin_int; @@ -10311,7 +10288,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, else { type = ada_index_type (arg1->type (), tem, - ada_attribute_name (op)); + attr_name); if (type == NULL) type = builtin_type (exp->gdbarch)->builtin_int; } @@ -10369,7 +10346,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, type = builtin_type (exp->gdbarch)->builtin_int; else { - type = ada_index_type (type_arg, tem, ada_attribute_name (op)); + type = ada_index_type (type_arg, tem, attr_name); if (type == NULL) type = builtin_type (exp->gdbarch)->builtin_int; }