From 6873858b7e464e114f9a877e216949ad8350b4cf Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 29 Mar 2018 14:14:07 -0600 Subject: Add inclusive range support for Rust This is version 2 of the patch to add inclusive range support for Rust. I believe it addresses all review comments. Rust recently stabilized the inclusive range feature: https://github.com/rust-lang/rust/issues/28237 An inclusive range is an expression like "..= EXPR" or "EXPR ..= EXPR". It is like an ordinary range, except the upper bound is inclusive, not exclusive. This patch adds support for this feature to gdb. Regression tested on x86-64 Fedora 27. 2018-04-27 Tom Tromey PR rust/22545: * rust-lang.c (rust_inclusive_range_type_p): New function. (rust_range): Handle inclusive ranges. (rust_compute_range): Likewise. * rust-exp.y (struct rust_op) : New field. (DOTDOTEQ): New constant. (range_expr): Add "..=" productions. (operator_tokens): Add "..=" token. (ast_range): Add "inclusive" parameter. (convert_ast_to_expression) : Handle inclusive ranges. * parse.c (operator_length_standard) : Handle new bounds values. * expression.h (enum range_type) : New constants. Update comments. * expprint.c (print_subexp_standard): Handle new bounds values. (dump_subexp_body_standard): Likewise. 2018-04-27 Tom Tromey PR rust/22545: * gdb.rust/simple.exp: Add inclusive range tests. --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.rust/simple.exp | 6 ++++++ 2 files changed, 11 insertions(+) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 34da102..22cf4ff 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-27 Tom Tromey + + PR rust/22545: + * gdb.rust/simple.exp: Add inclusive range tests. + 2018-04-26 Pedro Alves * gdb.base/gnu-ifunc.exp (set-break): Test that GDB resolves diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index d70de33..ba90e06 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -219,7 +219,9 @@ gdb_test "print r###\"###hello\"##" "Unexpected EOF in string" gdb_test "print r###\"hello###" "Unexpected EOF in string" gdb_test "print 0..5" " = .*::ops::Range.* \\{start: 0, end: 5\\}" +gdb_test "print 0..=5" " = .*::ops::RangeInclusive.* \\{start: 0, end: 5\\}" gdb_test "print ..5" " = .*::ops::RangeTo.* \\{end: 5\\}" +gdb_test "print ..=5" " = .*::ops::RangeToInclusive.* \\{end: 5\\}" gdb_test "print 5.." " = .*::ops::RangeFrom.* \\{start: 5\\}" gdb_test "print .." " = .*::ops::RangeFull" @@ -244,7 +246,9 @@ proc test_one_slice {svar length base range} { } test_one_slice slice 1 w 2..3 +test_one_slice slice 1 w 2..=2 test_one_slice slice2 1 slice 0..1 +test_one_slice slice2 1 slice 0..=0 test_one_slice all1 4 w .. test_one_slice all2 1 slice .. @@ -253,7 +257,9 @@ test_one_slice from1 3 w 1.. test_one_slice from2 0 slice 1.. test_one_slice to1 3 w ..3 +test_one_slice to1 3 w ..=2 test_one_slice to2 1 slice ..1 +test_one_slice to2 1 slice ..=0 gdb_test "print w\[2..3\]" "Can't take slice of array without '&'" -- cgit v1.1