Implement fortran_allocated_operation
[deliverable/binutils-gdb.git] / gdb / f-lang.c
index 6f7217dc94af453770570baceff5ffeb9c592f05..90ff3d155104cddd877dff5174940d4aee99b2f8 100644 (file)
@@ -995,6 +995,26 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang,
   return value_from_longest (result_type, is_associated ? 1 : 0);
 }
 
+struct value *
+eval_op_f_associated (struct type *expect_type,
+                     struct expression *exp,
+                     enum noside noside,
+                     enum exp_opcode opcode,
+                     struct value *arg1)
+{
+  return fortran_associated (exp->gdbarch, exp->language_defn, arg1);
+}
+
+struct value *
+eval_op_f_associated (struct type *expect_type,
+                     struct expression *exp,
+                     enum noside noside,
+                     enum exp_opcode opcode,
+                     struct value *arg1,
+                     struct value *arg2)
+{
+  return fortran_associated (exp->gdbarch, exp->language_defn, arg1, arg2);
+}
 
 /* A helper function for UNOP_ABS.  */
 
@@ -1189,7 +1209,7 @@ eval_op_f_kind (struct type *expect_type, struct expression *exp,
 
 /* A helper function for UNOP_FORTRAN_ALLOCATED.  */
 
-static struct value *
+struct value *
 eval_op_f_allocated (struct type *expect_type, struct expression *exp,
                     enum noside noside, enum exp_opcode op,
                     struct value *arg1)
@@ -1865,6 +1885,40 @@ fortran_undetermined::evaluate (struct type *expect_type,
     }
 }
 
+value *
+fortran_bound_1arg::evaluate (struct type *expect_type,
+                             struct expression *exp,
+                             enum noside noside)
+{
+  bool lbound_p = std::get<0> (m_storage) == FORTRAN_LBOUND;
+  value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+  fortran_require_array (value_type (arg1), lbound_p);
+  return fortran_bounds_all_dims (lbound_p, exp->gdbarch, arg1);
+}
+
+value *
+fortran_bound_2arg::evaluate (struct type *expect_type,
+                             struct expression *exp,
+                             enum noside noside)
+{
+  bool lbound_p = std::get<0> (m_storage) == FORTRAN_LBOUND;
+  value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+  fortran_require_array (value_type (arg1), lbound_p);
+
+  /* User asked for the bounds of a specific dimension of the array.  */
+  value *arg2 = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+  struct type *type = check_typedef (value_type (arg2));
+  if (type->code () != TYPE_CODE_INT)
+    {
+      if (lbound_p)
+       error (_("LBOUND second argument should be an integer"));
+      else
+       error (_("UBOUND second argument should be an integer"));
+    }
+
+  return fortran_bounds_for_dimension (lbound_p, exp->gdbarch, arg1, arg2);
+}
+
 } /* namespace expr */
 
 /* Special expression lengths for Fortran.  */
This page took 0.028898 seconds and 4 git commands to generate.