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/expprint.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'gdb/expprint.c') diff --git a/gdb/expprint.c b/gdb/expprint.c index c906904..047ec11 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -578,9 +578,13 @@ print_subexp_standard (struct expression *exp, int *pos, longest_to_int (exp->elts[pc + 1].longconst); *pos += 2; + if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE + || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE) + fputs_filtered ("EXCLUSIVE_", stream); fputs_filtered ("RANGE(", stream); if (range_type == HIGH_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT) + || range_type == NONE_BOUND_DEFAULT + || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE) print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered ("..", stream); if (range_type == LOW_BOUND_DEFAULT @@ -1099,12 +1103,18 @@ dump_subexp_body_standard (struct expression *exp, case LOW_BOUND_DEFAULT: fputs_filtered ("Range '..EXP'", stream); break; + case LOW_BOUND_DEFAULT_EXCLUSIVE: + fputs_filtered ("ExclusiveRange '..EXP'", stream); + break; case HIGH_BOUND_DEFAULT: fputs_filtered ("Range 'EXP..'", stream); break; case NONE_BOUND_DEFAULT: fputs_filtered ("Range 'EXP..EXP'", stream); break; + case NONE_BOUND_DEFAULT_EXCLUSIVE: + fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream); + break; default: fputs_filtered ("Invalid Range!", stream); break; -- cgit v1.1