diff options
author | Tom Tromey <tromey@adacore.com> | 2024-12-17 12:35:44 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-01-06 07:03:40 -0700 |
commit | 350609bb98cee92c6b4fbd334b99066683b9e5c1 (patch) | |
tree | c39e570d4c52168791b998dfd25fb6ab4579dcc1 /gdb/testsuite | |
parent | 03736207c6c81713c9ed749877de1c0e0ff3ffee (diff) | |
download | gdb-350609bb98cee92c6b4fbd334b99066683b9e5c1.zip gdb-350609bb98cee92c6b4fbd334b99066683b9e5c1.tar.gz gdb-350609bb98cee92c6b4fbd334b99066683b9e5c1.tar.bz2 |
Don't lex floating-point number in Rust field expression
Consider this Rust tuple:
let tuple_tuple = ((23i32, 24i32), 25i32);
Here, the value is a tuple whose first element is also a tuple.
You should be able to print this with:
(gdb) print tuple_tuple.0.1
However, currently the Rust lexer sees "0.1" as a floating-point
number.
This patch fixes the problem by introducing a special case in the
lexer: when parsing a field expression, the parser informs the lexer
that a number should be handled as a decimal integer only.
This change then lets us remove the decimal integer special case from
lex_number.
v2: I realized that the other DECIMAL_INTEGER cases aren't needed any
more.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32472
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.exp | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.rs | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 37a2e07..e269e41 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -138,7 +138,7 @@ gdb_test "print z.1" " = 8" # Some error checks. gdb_test "print z.1_0" \ - "'_' not allowed in integers in anonymous field references" + "Syntax error near '_0'" gdb_test "print z.mut" "field name expected" gdb_test "print univariant" " = simple::Univariant::Foo{a: 1}" @@ -424,3 +424,6 @@ gdb_test "print \$one = \$two = 75" " = \\\(\\\)" gdb_test "info symbol 0xffffffffffffffff" \ "No symbol matches 0xffffffffffffffff." + +# This used to confound the lexer into thinking "0.1" is a float. +gdb_test "print tuple_tuple.0.1" " = 24" diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs index 2dcbea2..d9d6b32 100644 --- a/gdb/testsuite/gdb.rust/simple.rs +++ b/gdb/testsuite/gdb.rust/simple.rs @@ -181,6 +181,8 @@ fn main () { let nonzero_offset = EnumWithNonzeroOffset { a: Some(1), b: None }; + let tuple_tuple = ((23i32, 24i32), 25i32); + println!("{}, {}", x.0, x.1); // set breakpoint here println!("{}", diff2(92, 45)); empty(); |