public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCHv5 2/4] gdb: rename 'enum range_type' to 'enum range_flag'
Date: Sun, 11 Oct 2020 19:12:11 +0100	[thread overview]
Message-ID: <21cf4b304f572a479094653aa60ffe7380ea3c1a.1602439661.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1602439661.git.andrew.burgess@embecosm.com>

To avoid confusion with other parts of GDB relating to types and
ranges, rename this enum to make it clearer that it is a set of
individual flags rather than an enumeration of different types of
range.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* expprint.c (print_subexp_standard): Change enum range_type to
	range_flag and rename variables to match.
	(dump_subexp_body_standard): Likewise.
	* expression.h (enum range_type): Rename to...
	(enum range_flag): ...this.
	(range_types): Rename to...
	(range_flags): ...this.
	* f-lang.c (value_f90_subarray): Change enum range_type to
	range_flag and rename variables to match.
	* parse.c (operator_length_standard): Likewise.
	* rust-exp.y (rust_parser::convert_ast_to_expression): Change enum
	range_type to range_flag.
	* rust-lang.c (rust_evaluate_funcall): Likewise.
	(rust_range): Likewise.
	(rust_compute_range): Likewise.
	(rust_subscript): Likewise.
---
 gdb/ChangeLog    | 19 +++++++++++++++++++
 gdb/expprint.c   | 24 ++++++++++++------------
 gdb/expression.h |  4 ++--
 gdb/f-lang.c     |  8 ++++----
 gdb/parse.c      |  8 ++++----
 gdb/rust-exp.y   |  2 +-
 gdb/rust-lang.c  |  8 ++++----
 7 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/gdb/expprint.c b/gdb/expprint.c
index bdb69a92f75..2dee2bb1932 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -579,19 +579,19 @@ print_subexp_standard (struct expression *exp, int *pos,
 
     case OP_RANGE:
       {
-	enum range_type range_type;
+	enum range_flag range_flag;
 
-	range_type = (enum range_type)
+	range_flag = (enum range_flag)
 	  longest_to_int (exp->elts[pc + 1].longconst);
 	*pos += 2;
 
-	if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
+	if (range_flag & RANGE_HIGH_BOUND_EXCLUSIVE)
 	  fputs_filtered ("EXCLUSIVE_", stream);
 	fputs_filtered ("RANGE(", stream);
-	if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
 	fputs_filtered ("..", stream);
-	if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
 	fputs_filtered (")", stream);
 	return;
@@ -1106,25 +1106,25 @@ dump_subexp_body_standard (struct expression *exp,
       break;
     case OP_RANGE:
       {
-	enum range_type range_type;
+	enum range_flag range_flag;
 
-	range_type = (enum range_type)
+	range_flag = (enum range_flag)
 	  longest_to_int (exp->elts[elt].longconst);
 	elt += 2;
 
-	if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE)
+	if (range_flag & RANGE_HIGH_BOUND_EXCLUSIVE)
 	  fputs_filtered ("Exclusive", stream);
 	fputs_filtered ("Range '", stream);
-	if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
 	  fputs_filtered ("EXP", stream);
 	fputs_filtered ("..", stream);
-	if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
 	  fputs_filtered ("EXP", stream);
 	fputs_filtered ("'", stream);
 
-	if (!(range_type & RANGE_LOW_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_LOW_BOUND_DEFAULT))
 	  elt = dump_subexp (exp, stream, elt);
-	if (!(range_type & RANGE_HIGH_BOUND_DEFAULT))
+	if (!(range_flag & RANGE_HIGH_BOUND_DEFAULT))
 	  elt = dump_subexp (exp, stream, elt);
       }
       break;
diff --git a/gdb/expression.h b/gdb/expression.h
index 6bd3fc0c3c5..fd483e5f277 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -185,7 +185,7 @@ extern void dump_prefix_expression (struct expression *, struct ui_file *);
    or inclusive.  So we have six sorts of subrange.  This enumeration
    type is to identify this.  */
 
-enum range_type : unsigned
+enum range_flag : unsigned
 {
   /* This is a standard range.  Both the lower and upper bounds are
      defined, and the bounds are inclusive.  */
@@ -201,6 +201,6 @@ enum range_type : unsigned
   RANGE_HIGH_BOUND_EXCLUSIVE = 1 << 2,
 };
 
-DEF_ENUM_FLAGS_TYPE (enum range_type, range_types);
+DEF_ENUM_FLAGS_TYPE (enum range_flag, range_flags);
 
 #endif /* !defined (EXPRESSION_H) */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index fcab973f874..37d05b27653 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -126,17 +126,17 @@ value_f90_subarray (struct value *array,
   int pc = (*pos) + 1;
   LONGEST low_bound, high_bound;
   struct type *range = check_typedef (value_type (array)->index_type ());
-  enum range_type range_type
-    = (enum range_type) longest_to_int (exp->elts[pc].longconst);
+  enum range_flag range_flag
+    = (enum range_flag) longest_to_int (exp->elts[pc].longconst);
 
   *pos += 3;
 
-  if (range_type & RANGE_LOW_BOUND_DEFAULT)
+  if (range_flag & RANGE_LOW_BOUND_DEFAULT)
     low_bound = range->bounds ()->low.const_val ();
   else
     low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
 
-  if (range_type & RANGE_HIGH_BOUND_DEFAULT)
+  if (range_flag & RANGE_HIGH_BOUND_DEFAULT)
     high_bound = range->bounds ()->high.const_val ();
   else
     high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
diff --git a/gdb/parse.c b/gdb/parse.c
index 6661fba81d7..4a15de8a499 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -774,7 +774,7 @@ operator_length_standard (const struct expression *expr, int endpos,
 {
   int oplen = 1;
   int args = 0;
-  enum range_type range_type;
+  enum range_flag range_flag;
   int i;
 
   if (endpos < 1)
@@ -918,15 +918,15 @@ operator_length_standard (const struct expression *expr, int endpos,
 
     case OP_RANGE:
       oplen = 3;
-      range_type = (enum range_type)
+      range_flag = (enum range_flag)
 	longest_to_int (expr->elts[endpos - 2].longconst);
 
       /* Assume the range has 2 arguments (low bound and high bound), then
 	 reduce the argument count if any bounds are set to default.  */
       args = 2;
-      if (range_type & RANGE_LOW_BOUND_DEFAULT)
+      if (range_flag & RANGE_LOW_BOUND_DEFAULT)
 	--args;
-      if (range_type & RANGE_HIGH_BOUND_DEFAULT)
+      if (range_flag & RANGE_HIGH_BOUND_DEFAULT)
 	--args;
 
       break;
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index ea9fbdc25fb..802ccc0a7f6 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2492,7 +2492,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
 
     case OP_RANGE:
       {
-	enum range_type kind = (RANGE_HIGH_BOUND_DEFAULT
+	enum range_flag kind = (RANGE_HIGH_BOUND_DEFAULT
 				| RANGE_LOW_BOUND_DEFAULT);
 
 	if (operation->left.op != NULL)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 820ebb92c43..86e7289c5e6 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1065,7 +1065,6 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
 static struct value *
 rust_range (struct expression *exp, int *pos, enum noside noside)
 {
-  enum range_type kind;
   struct value *low = NULL, *high = NULL;
   struct value *addrval, *result;
   CORE_ADDR addr;
@@ -1074,7 +1073,8 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
   struct type *temp_type;
   const char *name;
 
-  kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
+  auto kind
+    = (enum range_flag) longest_to_int (exp->elts[*pos + 1].longconst);
   *pos += 3;
 
   if (!(kind & RANGE_LOW_BOUND_DEFAULT))
@@ -1164,7 +1164,7 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
 static void
 rust_compute_range (struct type *type, struct value *range,
 		    LONGEST *low, LONGEST *high,
-		    range_types *kind)
+		    range_flags *kind)
 {
   int i;
 
@@ -1204,7 +1204,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
   struct type *rhstype;
   LONGEST low, high_bound;
   /* Initialized to appease the compiler.  */
-  range_types kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
+  range_flags kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
   LONGEST high = 0;
   int want_slice = 0;
 
-- 
2.25.4


  parent reply	other threads:[~2020-10-11 18:12 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 12:58 [PATCH 0/8] Fortran Array Slicing and Striding Support Andrew Burgess
2020-08-13 12:58 ` [PATCH 1/8] gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags Andrew Burgess
2020-08-15 17:16   ` Tom Tromey
2020-08-16  9:13     ` Andrew Burgess
2020-08-17 10:40     ` Andrew Burgess
2020-08-20 16:00       ` Pedro Alves
2020-08-21 14:49       ` Pedro Alves
2020-08-21 15:57         ` Andrew Burgess
2020-08-21 18:10           ` Pedro Alves
2020-08-13 12:58 ` [PATCH 2/8] gdbsupport: Make function arguments constant in enum-flags.h Andrew Burgess
2020-08-15 19:45   ` Tom Tromey
2020-08-16  9:08     ` Andrew Burgess
2020-08-13 12:58 ` [PATCH 3/8] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-08-13 12:58 ` [PATCH 4/8] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-08-13 12:58 ` [PATCH 5/8] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-08-13 12:58 ` [PATCH 6/8] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-13 12:58 ` [PATCH 7/8] gdb/testsuite: Add missing expected results Andrew Burgess
2020-08-13 12:58 ` [PATCH 8/8] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-13 13:31   ` Eli Zaretskii
2020-08-26 14:49 ` [PATCHv2 00/10] Fortran Array Slicing and Striding Support Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 01/10] Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502) Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 02/10] Use type_instance_flags more throughout Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 03/10] Rewrite enum_flags, add unit tests, fix problems Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 04/10] gdb: additional changes to make use of type_instance_flags more Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 05/10] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-09-19  8:53     ` Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 06/10] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-09-19  8:53     ` Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 07/10] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-09-19  8:54     ` Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 08/10] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 09/10] gdb/testsuite: Add missing expected results Andrew Burgess
2020-09-18  9:53     ` Andrew Burgess
2020-08-26 14:49   ` [PATCHv2 10/10] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-26 17:02     ` Eli Zaretskii
2020-09-19  9:47   ` [PATCHv3 0/2] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-19  9:48     ` [PATCHv3 1/2] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-19 13:50       ` Simon Marchi
2020-09-19  9:48     ` [PATCHv3 2/2] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-19 10:03       ` Eli Zaretskii
2020-09-28  9:40     ` [PATCHv4 0/3] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-28  9:40       ` [PATCHv4 1/3] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-28  9:40       ` [PATCHv4 2/3] gdb: rename 'enum range_type' to 'enum range_flag' Andrew Burgess
2020-09-28  9:40       ` [PATCHv4 3/3] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-28  9:52         ` Eli Zaretskii
2020-10-11 18:12       ` [PATCHv5 0/4] Fortran Array Slicing and Striding Support Andrew Burgess
2020-10-11 18:12         ` [PATCHv5 1/4] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-10-20 20:16           ` Tom Tromey
2020-10-11 18:12         ` Andrew Burgess [this message]
2020-10-20 20:16           ` [PATCHv5 2/4] gdb: rename 'enum range_type' to 'enum range_flag' Tom Tromey
2020-10-11 18:12         ` [PATCHv5 3/4] gdb/fortran: add support for parsing array strides in expressions Andrew Burgess
2020-10-12 13:21           ` Simon Marchi
2020-10-20 20:17           ` Tom Tromey
2020-10-22 10:42           ` Andrew Burgess
2020-10-11 18:12         ` [PATCHv5 4/4] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-10-12 14:10           ` Simon Marchi
2020-10-20 20:45           ` Tom Tromey
2020-10-29 11:08             ` Andrew Burgess
2020-10-31 22:16           ` [PATCHv6] " Andrew Burgess
2020-11-12 12:09             ` Andrew Burgess
2020-11-12 18:58             ` Tom Tromey
2020-11-19 11:56             ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21cf4b304f572a479094653aa60ffe7380ea3c1a.1602439661.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).