From patchwork Thu Mar 21 19:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87479 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 6D84A3858288 for ; Thu, 21 Mar 2024 19:06:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id F2106385840E for ; Thu, 21 Mar 2024 19:03:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2106385840E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F2106385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047823; cv=none; b=o9uvq5cKghvefWdU/3WPXPUOxhnFwOtP/WvA6gl4KICN8pSKqQUcuRNObznEzFtEFIjefEjBLR0ysU++qeQE+lIUmuIwwFjmCsk5RA9+zP3rxC3+ju1K3uYNesvjQkktgtz6r+NEemya0tPKz7cER00dMNV19HhfFW8kPpK8U9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047823; c=relaxed/simple; bh=gOK9VweWXYLp5fIk6+wphyrkdkc1YcTJjSRICLNnIkg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Gtn88pucI46hSVYnhnbLWYaD9ArcvE17ksAxMQiPeC3/tSUE98aK39/0w6E9ep15ee/JYV0KWtmJcYfDnu8q79fjPS4SOgn62A5PnAZkAZF8e/VLHAu0OiLf462TxBo5SHZVCh/7rbMZ+fc/8fPq7gKxDGTuXIouPJJmDVleHU4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7cf1a21ab1dso56540539f.2 for ; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047814; x=1711652614; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FN+Nt2/qeHzIPkN4QQwlcRp28h+5NoIDxevkp8Udk1M=; b=FX6f7QHdDAlhvXgSMmt92/KfCTxsoU5XBsLtvVu8EJIwJEJGS3kBRci3AxLWMeeqhf yEn7/8AH9lvR3WGlrA9awIQMnTf4g1e/kZd9MPUZN16ffdfbOJP7lpwYcoFqUvO15Y5T 480hn4QXksjENfqnn7exVA5VzPTe59fqU3wSvZxv4DwsO1yGiXWU56nElP/eyDdNjqz+ LHOABg/OwRrQEQ+dK4fdXX7yGJl686GtIOpg6qhBBGCgjpEtDgG5mf24N/jfFbPdH+Rt eeMJpsnqzup09062Ev3K3NwEnnOAoGiqM3vgpvRM8GDWLpre6ztt5ln8xRW9BRLlOJ2H dIFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047814; x=1711652614; 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=FN+Nt2/qeHzIPkN4QQwlcRp28h+5NoIDxevkp8Udk1M=; b=ZES+KI/Ot+se43IFTZodrkwreXrNY6TyhYinOCljGJkYBI8x75QuI2uPuCRc5F581a 6RckXd93O961nBPJKi6YxxgfAOvWOcr5zwdJA/Kio3wCFpxIEvpapGHqHg64IVOY2JlV rbvDtoJgYOO3M5y2b4uY8MpMXXWCfT24TSm0lALU2AqqLSI7rAffLdLWylqUcU6snRXa jxoKioeBrBLTb10dxfS+EVHpDFzoza6yUIoyEcAfk/5WffGWJhwbXZmSqUPx4p2763Ln +6vzN9ACthbjdsg0tQyvFytHkDQ1rZYpdkWqyE+dH1ciUioHTdAwmqw/MEAYLX3AA82d uh0w== X-Gm-Message-State: AOJu0YzrPJOqNbL6nTvU6Ck1UzQ8T7UMZDeWmVtwDmIBUQ53fPsWxEV+ e1oaPALA1FnpglW89e7l0X8PcOcy6h33DWMf7QjEITTDn4iTpfg6YfhMwYSAXogRZvBpq6sRZn0 = X-Google-Smtp-Source: AGHT+IECV6zFtutHFvmFTdfiwtAWQLhb1doa6eZ0gfByO3UU1X44PNBpywcne5YJJZaBM0KNFfKZwA== X-Received: by 2002:a6b:db11:0:b0:7cc:75fd:cd37 with SMTP id t17-20020a6bdb11000000b007cc75fdcd37mr378827ioc.19.1711047814089; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:33 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:39 -0600 Subject: [PATCH 11/12] Remove "numbuf" global MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-11-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The lexer has a "numbuf" global that is only used for temporary storage. This patch removes the global and redeclares it at the points of use. --- gdb/ada-lex.l | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 11221723eb3..4e99eaab036 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -59,9 +59,7 @@ DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER #define NUMERAL_WIDTH 256 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1)) -/* Temporary staging for numeric literals. */ -static char numbuf[NUMERAL_WIDTH]; - static void canonicalizeNumeral (char *s1, const char *); +static void canonicalizeNumeral (char *s1, const char *); static struct stoken processString (const char*, int); static int processInt (struct parser_state *, const char *, const char *, const char *); @@ -114,6 +112,7 @@ static void rewind_to_char (int); "--".* { yyterminate(); } {NUM10}{POSEXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); char *e_ptr = strrchr (numbuf, 'e'); *e_ptr = '\0'; @@ -121,11 +120,13 @@ static void rewind_to_char (int); } {NUM10} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processInt (pstate, NULL, numbuf, NULL); } {NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); char *e_ptr = strrchr (numbuf, 'e'); *e_ptr = '\0'; @@ -139,23 +140,27 @@ static void rewind_to_char (int); floating-point number is formed by reinterpreting the bytes, allowing direct control over the bits. */ {NUM10}(l{0,2}f)?"#"{HEXDIG}({HEXDIG}|_)*"#" { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processInt (pstate, numbuf, strchr (numbuf, '#') + 1, NULL); } "0x"{HEXDIG}+ { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext+2); return processInt (pstate, "16#", numbuf, NULL); } {NUM10}"."{NUM10}{EXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processReal (pstate, numbuf); } {NUM10}"."{NUM10} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processReal (pstate, numbuf); }