From bf2977b5f3d25779cdc06ba79c05244d70bd8b59 Mon Sep 17 00:00:00 2001
From: Weimin Pan <weimin.pan@oracle.com>
Date: Mon, 18 Jun 2018 21:15:13 +0000
Subject: Fix failure to find member of a typedef base class

The test case below demonstrates the problem, as described in this PR's Comment 5:

typedef struct {
        int x;
} A;

struct C : A {
        int y;
};

int main()
{
        C c;
        return 55;
}

$ gdb a.out
(gdb) ptype C::x
Internal error: non-aggregate type to value_struct_elt_for_reference

In value_struct_elt_for_reference(), need to call check_typedef() on
the aggregate type to handle the case of *curtype being ptr->typedef.

Tested on x86_64-linux. No regressions.
---
 gdb/valops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'gdb/valops.c')

diff --git a/gdb/valops.c b/gdb/valops.c
index 93374576841..9bdbf22b03c 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3343,7 +3343,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 				int want_address,
 				enum noside noside)
 {
-  struct type *t = curtype;
+  struct type *t = check_typedef (curtype);
   int i;
   struct value *v, *result;
 
-- 
cgit v1.2.1