public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 6/8] [gdb/rust] Fix literal truncation
Date: Thu, 26 May 2022 11:17:40 -0600	[thread overview]
Message-ID: <87v8ts6wnf.fsf@tromey.com> (raw)
In-Reply-To: <20220523110518.2447-6-tdevries@suse.de> (Tom de Vries via Gdb-patches's message of "Mon, 23 May 2022 13:05:16 +0200")

>>>>> "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.

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.

Tom

  reply	other threads:[~2022-05-26 17:17 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 [this message]
2022-06-07  9:29     ` Tom de Vries
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=87v8ts6wnf.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /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).