From 5747baa984d96241e4e2608da3c3e0160e32410b Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 5 May 2021 12:07:24 +0200 Subject: Generate debug info for local dynamic record types In Ada you can embed VLAs in local record types and thus end up with dynamic offsets in record types, which are not well described in DWARF because 1) the temporaries generated for them by the gimplifier are naturally marked DECL_IGNORED_P and 2) when the types are referenced in nested subprograms, the DWARF back-end does not correctly handle the rewritten references. gcc/ * dwarf2out.c (loc_list_from_tree_1) : During early DWARF, do not expand the VALUE_EXPR of variables put in the non-local frame. * gimplify.c (gimplify_type_sizes) : If the type is not to be ignored for debug info, ensure its variable offsets are not. gcc/testsuite/ * gnat.dg/debug8.adb: Minor tweak. * gnat.dg/debug11.adb: Likewise. * gnat.dg/debug16.adb: Likewise. * gnat.dg/debug17.adb: New test. * gnat.dg/specs/debug1.ads: Minor tweak. --- gcc/dwarf2out.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gcc/dwarf2out.c') diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index c36fd5a..5b819ab 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18658,8 +18658,20 @@ loc_list_from_tree_1 (tree loc, int want_address, case RESULT_DECL: if (DECL_HAS_VALUE_EXPR_P (loc)) - return loc_list_from_tree_1 (DECL_VALUE_EXPR (loc), - want_address, context); + { + tree value_expr = DECL_VALUE_EXPR (loc); + + /* Non-local frame structures are DECL_IGNORED_P variables so we need + to wait until they get an RTX in order to reference them. */ + if (early_dwarf + && TREE_CODE (value_expr) == COMPONENT_REF + && VAR_P (TREE_OPERAND (value_expr, 0)) + && DECL_NONLOCAL_FRAME (TREE_OPERAND (value_expr, 0))) + ; + else + return loc_list_from_tree_1 (value_expr, want_address, context); + } + /* FALLTHRU */ case FUNCTION_DECL: -- cgit v1.1