This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/5] Fortran: Change subrange enum to bit field.


On 2017-09-11 14:57, Tim Wiederhake wrote:
From: Christoph Weinmann <christoph.t.weinmann@intel.com>

Change Fortran subrange enum for subrange expressions to represent a bitfield for easier manipulation. Consequently also change occurences and evaluation
of said enum.  The behaviour of GDB is unchanged.

Good idea, I think it makes sense. It might be useful if this enum was an "enum flags" in some cases (like to avoid having to cast when doing bitwise or), but it may not help in other. For example, I am not sure the

  case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND):

would work. You can try it if you want, but otherwise I'm fine with the current version.

xxxx-yy-zz  Christoph Weinmann  <christoph.t.weinmann@intel.com>
            Tim Wiederhake  <tim.wiederhake@intel.com>

	* expprint.c (print_subexp_standard): Use bitfield instead of enum.
	(dump_subexp_body_standard): Same.
	* f-exp.y (subrange): Same.
	* f-lang.c (f90_value_subarray): Same.
	* parse.c (operator_length_standard): Same.
	* rust-exp.y: Same.
	* rust-lang.c (rust_range, rust_compute_range, rust_subscript): Same.
	* expression.h (enum range_type): Turn into a bitfield.


---
 gdb/expprint.c   | 20 ++++++++------------
 gdb/expression.h | 15 ++++++---------
 gdb/f-exp.y      | 11 ++++++-----
 gdb/f-lang.c     |  8 ++++----
 gdb/parse.c      | 21 ++++++++-------------
 gdb/rust-exp.y   | 12 +++---------
 gdb/rust-lang.c  | 17 ++++++++---------
 7 files changed, 43 insertions(+), 61 deletions(-)

diff --git a/gdb/expprint.c b/gdb/expprint.c
index 9e04f24..19d1c88 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -581,12 +581,10 @@ print_subexp_standard (struct expression *exp, int *pos,
 	*pos += 2;

 	fputs_filtered ("RANGE(", stream);
-	if (range_type == HIGH_BOUND_DEFAULT
-	    || range_type == NONE_BOUND_DEFAULT)
+	if ((range_type & SUBARRAY_LOW_BOUND) != 0)
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
 	fputs_filtered ("..", stream);
-	if (range_type == LOW_BOUND_DEFAULT
-	    || range_type == NONE_BOUND_DEFAULT)
+	if ((range_type & SUBARRAY_HIGH_BOUND) != 0)
 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
 	fputs_filtered (")", stream);
 	return;
@@ -1093,16 +1091,16 @@ dump_subexp_body_standard (struct expression *exp,

 	switch (range_type)
 	  {
-	  case BOTH_BOUND_DEFAULT:
+	  case SUBARRAY_NO_BOUND:
 	    fputs_filtered ("Range '..'", stream);
 	    break;
-	  case LOW_BOUND_DEFAULT:
+	  case SUBARRAY_HIGH_BOUND:
 	    fputs_filtered ("Range '..EXP'", stream);
 	    break;
-	  case HIGH_BOUND_DEFAULT:
+	  case SUBARRAY_LOW_BOUND:
 	    fputs_filtered ("Range 'EXP..'", stream);
 	    break;
-	  case NONE_BOUND_DEFAULT:
+	  case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND):
 	    fputs_filtered ("Range 'EXP..EXP'", stream);
 	    break;
 	  default:
@@ -1110,11 +1108,9 @@ dump_subexp_body_standard (struct expression *exp,
 	    break;
 	  }

-	if (range_type == HIGH_BOUND_DEFAULT
-	    || range_type == NONE_BOUND_DEFAULT)
+	if ((range_type & SUBARRAY_LOW_BOUND) != 0)
 	  elt = dump_subexp (exp, stream, elt);
-	if (range_type == LOW_BOUND_DEFAULT
-	    || range_type == NONE_BOUND_DEFAULT)
+	if ((range_type & SUBARRAY_HIGH_BOUND) != 0)
 	  elt = dump_subexp (exp, stream, elt);
       }
       break;
diff --git a/gdb/expression.h b/gdb/expression.h
index 9e4ddf5..c794198 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -155,17 +155,14 @@ extern void dump_raw_expression (struct expression *,
 				 struct ui_file *, const char *);
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.  */
-
+/* Flags to indicate which boundarys are set in an OP_RANGE expression. Values

boundarys -> boundaries

Thanks,

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]