From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 64A113858400; Mon, 6 Sep 2021 09:18:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64A113858400 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3366] Fix debug info for packed array types in Ada X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 8a4602c2e0f81895415ba7ee23bf81dc795d1103 X-Git-Newrev: c0b03afeab4502da3040ef1ebbd28f826737fa8a Message-Id: <20210906091841.64A113858400@sourceware.org> Date: Mon, 6 Sep 2021 09:18:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2021 09:18:41 -0000 https://gcc.gnu.org/g:c0b03afeab4502da3040ef1ebbd28f826737fa8a commit r12-3366-gc0b03afeab4502da3040ef1ebbd28f826737fa8a Author: Eric Botcazou Date: Mon Sep 6 11:16:08 2021 +0200 Fix debug info for packed array types in Ada Packed array types are sometimes represented with integer types under the hood in Ada, but we nevertheless need to emit them as array types in the debug info so we have the types.get_array_descr_info langhook for this purpose; but it is not invoked from modified_type_die, which causes: FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3) in the GDB testsuite. gcc/ * dwarf2out.c (modified_type_die): Deal with all array types earlier and use local variable consistently throughout the function. Diff: --- gcc/dwarf2out.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 07a479f6382..4f100606618 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -13542,6 +13542,7 @@ modified_type_die (tree type, int cv_quals, bool reverse, tree qualified_type; tree name, low, high; dw_die_ref mod_scope; + struct array_descr_info info; /* Only these cv-qualifiers are currently handled. */ const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC | @@ -13786,6 +13787,13 @@ modified_type_die (tree type, int cv_quals, bool reverse, } } } + else if (code == ARRAY_TYPE + || (lang_hooks.types.get_array_descr_info + && lang_hooks.types.get_array_descr_info (type, &info))) + { + gen_type_die (type, context_die); + return lookup_type_die (type); + } else if (code == INTEGER_TYPE && TREE_TYPE (type) != NULL_TREE && subrange_type_for_debug_p (type, &low, &high)) @@ -13822,8 +13830,7 @@ modified_type_die (tree type, int cv_quals, bool reverse, copy was created to help us keep track of typedef names) and that copy might have a different TYPE_UID from the original ..._TYPE node. */ - if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (code == FUNCTION_TYPE || code == METHOD_TYPE) { /* For function/method types, can't just use type_main_variant here, because that can have different ref-qualifiers for C++, @@ -13836,13 +13843,12 @@ modified_type_die (tree type, int cv_quals, bool reverse, return lookup_type_die (t); return lookup_type_die (type); } - else if (TREE_CODE (type) != VECTOR_TYPE - && TREE_CODE (type) != ARRAY_TYPE) - return lookup_type_die (type_main_variant (type)); - else - /* Vectors have the debugging information in the type, - not the main variant. */ + /* Vectors have the debugging information in the type, + not the main variant. */ + else if (code == VECTOR_TYPE) return lookup_type_die (type); + else + return lookup_type_die (type_main_variant (type)); } /* Builtin types don't have a DECL_ORIGINAL_TYPE. For those,