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/expression.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'gdb/expression.h') diff --git a/gdb/expression.h b/gdb/expression.h index 7abd7f7..9f26bb8 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -150,15 +150,26 @@ extern void dump_prefix_expression (struct expression *, struct ui_file *); /* In an OP_RANGE expression, either bound could be empty, indicating that its value is by default that of the corresponding bound of the - array or string. So we have four sorts of subrange. This - enumeration type is to identify this. */ - + array or string. Also, the upper end of the range can be exclusive + or inclusive. So we have six sorts of subrange. This enumeration + type is to identify this. */ + enum range_type - { - BOTH_BOUND_DEFAULT, /* "(:)" */ - LOW_BOUND_DEFAULT, /* "(:high)" */ - HIGH_BOUND_DEFAULT, /* "(low:)" */ - NONE_BOUND_DEFAULT /* "(low:high)" */ - }; +{ + /* Neither the low nor the high bound was given -- so this refers to + the entire available range. */ + BOTH_BOUND_DEFAULT, + /* The low bound was not given and the high bound is inclusive. */ + LOW_BOUND_DEFAULT, + /* The high bound was not given and the low bound in inclusive. */ + HIGH_BOUND_DEFAULT, + /* Both bounds were given and both are inclusive. */ + NONE_BOUND_DEFAULT, + /* The low bound was not given and the high bound is exclusive. */ + NONE_BOUND_DEFAULT_EXCLUSIVE, + /* Both bounds were given. The low bound is inclusive and the high + bound is exclusive. */ + LOW_BOUND_DEFAULT_EXCLUSIVE, +}; #endif /* !defined (EXPRESSION_H) */ -- cgit v1.1