Blame SOURCES/gdb-fortran-stride-intel-3of6.patch

be09dc
http://sourceware.org/ml/gdb-patches/2016-02/msg00845.html
be09dc
Subject: [PATCH v2 3/6] fortran: change subrange enum to bit field
be09dc
be09dc
From: Christoph Weinmann <christoph.t.weinmann@intel.com>
be09dc
be09dc
Change Fortran subrange enum for subrange expressions to
be09dc
represent a bitfield for easier manipulation.  Consequently
be09dc
also change occurences and evaluation of said enum.  The
be09dc
behaviour of GDB is unchanged.
be09dc
be09dc
2013-11-27  Christoph Weinmann  <christoph.t.weinmann@intel.com>
be09dc
be09dc
	* eval.c (value_f90_subarray): Change evaluation of the
be09dc
	subarray boundaries.  Set boundaries to be either user
be09dc
	provided (bit in f90_range_type was set) or take the
be09dc
	default value if the boundary was not provided by the user.
be09dc
	* f-exp.y (subrange): Change rules for subrange expressions
be09dc
	to write the relevant bit sequence onto the elt stack.
be09dc
	* f-lang.h (f90_range_type): Change the enum to use bit
be09dc
	values for each boundary, if set by the user.
be09dc
	* parse.c (operator_length_standard): In case of
be09dc
	OP_F90_RANGE change the calculation of the number of
be09dc
	arguments on the elt stack, depending on the number of
be09dc
	boundaries provided by the user.
be09dc
be09dc
be09dc
Signed-off-by: Christoph Weinmann <christoph.t.weinmann@intel.com>
be09dc
---
be09dc
 gdb/eval.c   | 14 ++++++--------
be09dc
 gdb/f-exp.y  | 11 ++++++-----
be09dc
 gdb/f-lang.h |  6 ++----
be09dc
 gdb/parse.c  | 21 ++++++++-------------
be09dc
 4 files changed, 22 insertions(+), 30 deletions(-)
be09dc
be09dc
diff --git a/gdb/eval.c b/gdb/eval.c
be09dc
index 164d7ab..9b8b051 100644
be09dc
--- a/gdb/eval.c
be09dc
+++ b/gdb/eval.c
be09dc
@@ -480,12 +480,12 @@ value_f90_subarray (struct value *array, struct expression *exp,
be09dc
 	  /* If a lower bound was provided by the user, the bit has been
be09dc
 	     set and we can assign the value from the elt stack.  Same for
be09dc
 	     upper bound.  */
be09dc
-	  if ((range->f90_range_type == HIGH_BOUND_DEFAULT)
be09dc
-	      || range->f90_range_type == NONE_BOUND_DEFAULT)
be09dc
+	  if ((range->f90_range_type & SUBARRAY_LOW_BOUND)
be09dc
+	      == SUBARRAY_LOW_BOUND)
be09dc
 	    range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp,
be09dc
 							 pos, noside));
be09dc
-	  if ((range->f90_range_type == LOW_BOUND_DEFAULT)
be09dc
-	      || range->f90_range_type == NONE_BOUND_DEFAULT)
be09dc
+	  if ((range->f90_range_type & SUBARRAY_HIGH_BOUND)
be09dc
+	      == SUBARRAY_HIGH_BOUND)
be09dc
 	    range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
be09dc
 							  pos, noside));
be09dc
 	}
be09dc
@@ -526,12 +526,10 @@ value_f90_subarray (struct value *array, struct expression *exp,
be09dc
 
be09dc
 	    /* If no lower bound was provided by the user, we take the
be09dc
 	       default boundary.  Same for the high bound.  */
be09dc
-	    if ((range->f90_range_type == LOW_BOUND_DEFAULT)
be09dc
-		|| (range->f90_range_type == BOTH_BOUND_DEFAULT))
be09dc
+	    if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0)
be09dc
 	      range->low = TYPE_LOW_BOUND (index_type);
be09dc
 
be09dc
-	    if ((range->f90_range_type == HIGH_BOUND_DEFAULT)
be09dc
-		|| (range->f90_range_type == BOTH_BOUND_DEFAULT))
be09dc
+	    if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0)
be09dc
 	      range->high = TYPE_HIGH_BOUND (index_type);
be09dc
 
be09dc
 	    /* Both user provided low and high bound have to be inside the
be09dc
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
be09dc
index 9343abb..b1206de 100644
be09dc
--- a/gdb/f-exp.y
be09dc
+++ b/gdb/f-exp.y
be09dc
@@ -315,26 +315,27 @@ arglist	:	arglist ',' exp   %prec ABOVE_COMMA
be09dc
 /* There are four sorts of subrange types in F90.  */
be09dc
 
be09dc
 subrange:	exp ':' exp	%prec ABOVE_COMMA
be09dc
-			{ write_exp_elt_opcode (pstate, OP_F90_RANGE); 
be09dc
-			  write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
be09dc
+			{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
be09dc
+			  write_exp_elt_longcst (pstate,
be09dc
+						 SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
be09dc
 			  write_exp_elt_opcode (pstate, OP_F90_RANGE); }
be09dc
 	;
be09dc
 
be09dc
 subrange:	exp ':'	%prec ABOVE_COMMA
be09dc
 			{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
be09dc
-			  write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
be09dc
+			  write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND);
be09dc
 			  write_exp_elt_opcode (pstate, OP_F90_RANGE); }
be09dc
 	;
be09dc
 
be09dc
 subrange:	':' exp	%prec ABOVE_COMMA
be09dc
 			{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
be09dc
-			  write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
be09dc
+			  write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND);
be09dc
 			  write_exp_elt_opcode (pstate, OP_F90_RANGE); }
be09dc
 	;
be09dc
 
be09dc
 subrange:	':'	%prec ABOVE_COMMA
be09dc
 			{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
be09dc
-			  write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
be09dc
+			  write_exp_elt_longcst (pstate, 0);
be09dc
 			  write_exp_elt_opcode (pstate, OP_F90_RANGE); }
be09dc
 	;
be09dc
 
be09dc
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
be09dc
index eeca107..4d56bf7 100644
be09dc
--- a/gdb/f-lang.h
be09dc
+++ b/gdb/f-lang.h
be09dc
@@ -44,10 +44,8 @@ extern void f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
be09dc
    
be09dc
 enum f90_range_type
be09dc
   {
be09dc
-    BOTH_BOUND_DEFAULT,		/* "(:)"  */
be09dc
-    LOW_BOUND_DEFAULT,		/* "(:high)"  */
be09dc
-    HIGH_BOUND_DEFAULT,		/* "(low:)"  */
be09dc
-    NONE_BOUND_DEFAULT		/* "(low:high)"  */
be09dc
+    SUBARRAY_LOW_BOUND = 0x1,		/* "(low:)"  */
be09dc
+    SUBARRAY_HIGH_BOUND = 0x2		/* "(:high)"  */
be09dc
   };
be09dc
 
be09dc
 /* A common block.  */
be09dc
diff --git a/gdb/parse.c b/gdb/parse.c
be09dc
index 4191fc6..d500279 100644
be09dc
--- a/gdb/parse.c
be09dc
+++ b/gdb/parse.c
be09dc
@@ -1006,22 +1006,17 @@ operator_length_standard (const struct expression *expr, int endpos,
be09dc
 
be09dc
     case OP_F90_RANGE:
be09dc
       oplen = 3;
be09dc
+      args = 0;
be09dc
       range_type = (enum f90_range_type)
be09dc
 	longest_to_int (expr->elts[endpos - 2].longconst);
be09dc
 
be09dc
-      switch (range_type)
be09dc
-	{
be09dc
-	case LOW_BOUND_DEFAULT:
be09dc
-	case HIGH_BOUND_DEFAULT:
be09dc
-	  args = 1;
be09dc
-	  break;
be09dc
-	case BOTH_BOUND_DEFAULT:
be09dc
-	  args = 0;
be09dc
-	  break;
be09dc
-	case NONE_BOUND_DEFAULT:
be09dc
-	  args = 2;
be09dc
-	  break;
be09dc
-	}
be09dc
+      /* Increment the argument counter for each argument
be09dc
+	 provided by the user.  */
be09dc
+      if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
be09dc
+	args++;
be09dc
+
be09dc
+      if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
be09dc
+	args++;
be09dc
 
be09dc
       break;
be09dc
 
be09dc
-- 
be09dc
2.5.0
be09dc