public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
	Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 6/8] [gdb/rust] Fix literal truncation
Date: Tue, 7 Jun 2022 11:29:22 +0200	[thread overview]
Message-ID: <4df16ebf-bbe3-aded-880b-0a76956685f1@suse.de> (raw)
In-Reply-To: <87v8ts6wnf.fsf@tromey.com>

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

On 5/26/22 19:17, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> Make sure we error out on overflow instead of truncating in all cases.
> Tom> I've used as overflow string: "Integer literal is too large", based
> Tom> on what I found at
> Tom> <rust-lang/rust>/src/test/ui/parser/int-literal-too-large-span.rs
> Tom> but perhaps someone has a better idea.
> 
> Tom> -      value = strtoulst (number.c_str () + offset, NULL, radix);
> Tom> +      const char *trailer;
> Tom> +      value = strtoulst (number.c_str () + offset, &trailer, radix);
> Tom> +      if (*trailer != '\0')
> Tom> +	error ("Integer literal is too large");
> 
> This seems fine, though I think it's normal to use _() around the
> argument to error.
> 

Indeed, and I forgot to follow up on that before commit.  Fixed in this 
commit.

> Tom> +	} elseif { $lang == "rust" } {
> Tom> +	    set re_overflow "Integer literal is too large"
> 
> I don't mind if this is there, but normally the Rust lexer uses unit
> tests.  They are in rust-parse.c, see rust_lex_tests.

Ack, and I did wonder whether it would be a good idea to port the entire 
test-case to the unit tests, since it might help with the test duration 
and enable us to test for all archs again.

For now though, I'm leaving things as they are.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-rust-Add-missing-_-for-error-call.patch --]
[-- Type: text/x-patch, Size: 786 bytes --]

[gdb/rust] Add missing _() for error call

In commit 1390b65a1b9 ("[gdb/rust] Fix literal truncation") I forgot to add
_() around a string using in an error call.

Fix this by adding the missing _().

Tested on x86_64-linux.

---
 gdb/rust-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 836f49108f8..f5eb63ec1e3 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -1027,7 +1027,7 @@ rust_parser::lex_number ()
       const char *trailer;
       value = strtoulst (number.c_str () + offset, &trailer, radix);
       if (*trailer != '\0')
-	error ("Integer literal is too large");
+	error (_("Integer literal is too large"));
       if (implicit_i32 && value >= ((uint64_t) 1) << 31)
 	type = get_type ("i64");
 

  reply	other threads:[~2022-06-07  9:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 11:05 [PATCH 1/8] [gdb/testsuite] Test more values in gdb.base/parse_numbers.exp Tom de Vries
2022-05-23 11:05 ` [PATCH 2/8] [gdb/c] Fix type of 2147483648 and literal truncation Tom de Vries
2022-05-23 11:05 ` [PATCH 3/8] [gdb/fortran] Fix " Tom de Vries
2022-05-23 11:05 ` [PATCH 4/8] [gdb/go] " Tom de Vries
2022-05-23 11:05 ` [PATCH 5/8] [gdb/pascal] " Tom de Vries
2022-05-23 11:05 ` [PATCH 6/8] [gdb/rust] " Tom de Vries
2022-05-26 17:17   ` Tom Tromey
2022-06-07  9:29     ` Tom de Vries [this message]
2022-05-23 11:05 ` [PATCH 7/8] [gdb/m2] Fix UB and " Tom de Vries
2022-05-23 11:05 ` [PATCH 8/8] [gdb/ada] Fix " Tom de Vries
2022-06-04 11:20 ` [PATCH 1/8] [gdb/testsuite] Test more values in gdb.base/parse_numbers.exp Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4df16ebf-bbe3-aded-880b-0a76956685f1@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).