From 31dbc1c5396158c36dc3619c0711f179a9458239 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@gnat.com>
Date: Tue, 9 Feb 2010 13:15:10 +0000
Subject: [PATCH] Wrong type description for tagged type parameter.

        * ada-lang.c (ada_evaluate_subexp) [OP_VAR_VALUE]: When noside is
        EVAL_AVOID_SIDE_EFFECTS, also handle the case when type is a
        reference to a tagged type.
---
 gdb/ChangeLog  | 7 +++++++
 gdb/ada-lang.c | 9 ++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ceb22c0c946..cbaeb4bdb11 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2010-02-09  Joel Brobecker  <brobecker@adacore.com>
+
+	Wrong type description for tagged type parameter.
+	* ada-lang.c (ada_evaluate_subexp) [OP_VAR_VALUE]: When noside is
+	EVAL_AVOID_SIDE_EFFECTS, also handle the case when type is a
+	reference to a tagged type.
+
 2010-02-09  Tristan Gingold  <gingold@adacore.com>
 
 	* objfiles.c (objfile_separate_debug_iterate): Do not iterate on
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 40b70ab5cc7..7a2d2ca84e1 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8906,7 +8906,14 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       else if (noside == EVAL_AVOID_SIDE_EFFECTS)
         {
           type = static_unwrap_type (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
-          if (ada_is_tagged_type (type, 0))
+          /* Check to see if this is a tagged type.  We also need to handle
+             the case where the type is a reference to a tagged type, but
+             we have to be careful to exclude pointers to tagged types.
+             The latter should be shown as usual (as a pointer), whereas
+             a reference should mostly be transparent to the user.  */
+          if (ada_is_tagged_type (type, 0)
+              || (TYPE_CODE(type) == TYPE_CODE_REF
+                  && ada_is_tagged_type (TYPE_TARGET_TYPE (type), 0)))
           {
             /* Tagged types are a little special in the fact that the real
                type is dynamic and can only be determined by inspecting the
-- 
GitLab