Introduce ada_var_msym_value_operation
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:34 +0000 (07:28 -0700)
This adds class ada_var_msym_value_operation, which implements
OP_VAR_MSYM_VALUE for Ada.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_var_msym_value_operation::evaluate_for_cast):
New method.
* ada-exp.h (class ada_var_msym_value_operation): New.

gdb/ChangeLog
gdb/ada-exp.h
gdb/ada-lang.c

index adf910fddbdb76a7bef5337a71280176e1b7be69..34f80b444866e51c25f553ae88000b7b8c67732c 100644 (file)
@@ -1,3 +1,9 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * ada-lang.c (ada_var_msym_value_operation::evaluate_for_cast):
+       New method.
+       * ada-exp.h (class ada_var_msym_value_operation): New.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (ada_var_value_operation::evaluate_for_cast)
index 0f2f62f5978ba67e877664d5cf32ef2a859c6a9d..0fe6ecf7e93a45cb302a529add2bc3b691bd8534 100644 (file)
@@ -304,6 +304,23 @@ protected:
   using operation::do_generate_ax;
 };
 
+/* Variant of var_msym_value_operation for Ada.  */
+class ada_var_msym_value_operation
+  : public var_msym_value_operation
+{
+public:
+
+  using var_msym_value_operation::var_msym_value_operation;
+
+  value *evaluate_for_cast (struct type *expect_type,
+                           struct expression *exp,
+                           enum noside noside) override;
+
+protected:
+
+  using operation::do_generate_ax;
+};
+
 } /* namespace expr */
 
 #endif /* ADA_EXP_H */
index ee8e8e12d0d1574fbc5e408818331d12d89bcea6..eb21748ef6aee430d9270b45764ba080e628d152 100644 (file)
@@ -10553,6 +10553,31 @@ ada_unop_atr_operation::evaluate (struct type *expect_type,
                       val, type_arg, std::get<2> (m_storage));
 }
 
+value *
+ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type,
+                                                struct expression *exp,
+                                                enum noside noside)
+{
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
+    return value_zero (expect_type, not_lval);
+
+  value *val = evaluate_var_msym_value (noside,
+                                       std::get<1> (m_storage),
+                                       std::get<0> (m_storage));
+
+  val = ada_value_cast (expect_type, val);
+
+  /* Follow the Ada language semantics that do not allow taking
+     an address of the result of a cast (view conversion in Ada).  */
+  if (VALUE_LVAL (val) == lval_memory)
+    {
+      if (value_lazy (val))
+       value_fetch_lazy (val);
+      VALUE_LVAL (val) = not_lval;
+    }
+  return val;
+}
+
 value *
 ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
                                            struct expression *exp,