From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oOFfFJpRHmK2ewAAWB0awg (envelope-from ) for ; Tue, 01 Mar 2022 12:02:18 -0500 Received: by simark.ca (Postfix, from userid 112) id 4E9991F3CA; Tue, 1 Mar 2022 12:02:18 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham 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 AB33C1EA69 for ; Tue, 1 Mar 2022 12:02:17 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BD643858C74 for ; Tue, 1 Mar 2022 17:02:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BD643858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1646154137; bh=5rVA0OIoQTO7seTAdlqsxmvO2kOEkZGtz+9P+cDbniw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=A6TYwgwgB3Ea7kEES1ZzVQ8Oop9DFK/8jMQH7SE9iUxwTvBrQ8pVskEja/35HU6un aRymJ3VgD4MeH15Jk8HKty/vNgY1HGKvfw9yUvDpOH78MvoWkXzRxRyxhsOD1SAIsG VVBRPgyIvevJONfb8COP5BjlzKSu8rkPM/UBNxq0= Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id AFC843858C60 for ; Tue, 1 Mar 2022 17:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AFC843858C60 Received: by mail-io1-xd36.google.com with SMTP id r8so5588658ioj.9 for ; Tue, 01 Mar 2022 09:00:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5rVA0OIoQTO7seTAdlqsxmvO2kOEkZGtz+9P+cDbniw=; b=Zk+wLCO2m1dPvEvYNrGwZ4sS2VK1XorU6s4nWp8A8GnnLJOX43EwEsa4qU0SFIb7vo 4sEZf7d3XnqIOXkJrP39mJA4lmt5TXIwBqwgRF3pTcvIj0Sru6tANFchCcOCTv8++JvE X8rMUIppLxV/GJ/uIGEi1CdMSvYQi4VHahsxE40ddrTLgZ4eb1Sksv+WrI52oYpV8fu3 YwSu27bT+Abt8GP1Q1h1bvz+uzsJLCoh4BS41+7NWnDT/ymqVzpSX5FfNQb9CZmyx8j3 nmqT6frI4QkfjLC/syI/U+6cRqW//s6u20pQ+PCwIGuYQC+2X/yqcsVH0X7w6gJ1NA75 jcXA== X-Gm-Message-State: AOAM533DxHwUZ7Tm7eHsTZn0SSmmqofTM+Ik11lD+F00sGyFSlvDNyMW 5Ehqf95kOmNOIZU7YxRq6JdFgkC/5u0+CQ== X-Google-Smtp-Source: ABdhPJy3iUP7JIfqJp7F7olRS5ib334CBjv+g8TaRJN7nN+pDUAxxZWhO4KavxVbJtkepgvsDgqEVg== X-Received: by 2002:a02:2406:0:b0:317:1aea:c8a4 with SMTP id f6-20020a022406000000b003171aeac8a4mr13945162jaa.65.1646154057967; Tue, 01 Mar 2022 09:00:57 -0800 (PST) Received: from murgatroyd.Home (75-166-141-253.hlrn.qwest.net. [75.166.141.253]) by smtp.gmail.com with ESMTPSA id 6-20020a056e0211a600b002c2494a5479sm8214281ilj.2.2022.03.01.09.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 09:00:57 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH 1/3] Fix Ada integer literals with exponents Date: Tue, 1 Mar 2022 10:00:53 -0700 Message-Id: <20220301170055.1520935-2-tromey@adacore.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220301170055.1520935-1-tromey@adacore.com> References: <20220301170055.1520935-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" While working on another patch, I noticed that Ada integer literals with exponents did not work. For example, with one form you get an error: (gdb) print 8e2 Invalid digit `e' in based literal And with another form you get an incorrect value: (gdb) print 16#8#e2 $2 = 8 This patch fixes the bugs and adds tests. --- gdb/ada-lex.l | 9 +++++--- gdb/testsuite/gdb.ada/literals.exp | 36 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.ada/literals.exp diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index f61efba81a9..aab53b397ec 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -103,8 +103,9 @@ static int paren_depth; {NUM10}{POSEXP} { canonicalizeNumeral (numbuf, yytext); - return processInt (pstate, NULL, numbuf, - strrchr (numbuf, 'e') + 1); + char *e_ptr = strrchr (numbuf, 'e'); + *e_ptr = '\0'; + return processInt (pstate, nullptr, numbuf, e_ptr + 1); } {NUM10} { @@ -114,9 +115,11 @@ static int paren_depth; {NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} { canonicalizeNumeral (numbuf, yytext); + char *e_ptr = strrchr (numbuf, 'e'); + *e_ptr = '\0'; return processInt (pstate, numbuf, strchr (numbuf, '#') + 1, - strrchr(numbuf, '#') + 1); + e_ptr + 1); } {NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#" { diff --git a/gdb/testsuite/gdb.ada/literals.exp b/gdb/testsuite/gdb.ada/literals.exp new file mode 100644 index 00000000000..92a9a1954fc --- /dev/null +++ b/gdb/testsuite/gdb.ada/literals.exp @@ -0,0 +1,36 @@ +# Copyright 2022 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test some literal syntax. + +load_lib "ada.exp" + +if { [skip_ada_tests] } { return -1 } + +clean_restart + +gdb_test_no_output "set lang ada" +gdb_test "print 7#10#" " = 7" +gdb_test "print 77#10#" "Invalid base: 77." +gdb_test "print 7#8#" "Invalid digit `8' in based literal" + +gdb_test "print 8e2" " = 800" +gdb_test "print 9999999999999999999999999999999999999999999999" \ + "Integer literal out of range" +gdb_test "print 2e1000" "Integer literal out of range" + +gdb_test "print 16#ffff#" " = 65535" +gdb_test "print 16#f#e1" " = 240" +gdb_test "print 16#1#e10" " = 1099511627776" -- 2.31.1