[PATCH 6/8] [gdb/rust] Fix literal truncation
Tom Tromey
tom@tromey.com
Thu May 26 17:17:40 GMT 2022
>>>>> "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
More information about the Gdb-patches
mailing list