From patchwork Sat Sep 9 13:05:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 811959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461775-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NsXAIj+c"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xqDvp6GkLz9s76 for ; Sat, 9 Sep 2017 23:05:56 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=sAFlvIVj7N482WrY +C1yuAvrjWE43Bhcr/z6uSdcUUuQlnA72BRecp9ERkmclf2hGQW8QzTyJBMabNJF hrWY64j1/7eaNOb3DxjoQ+TVoObk0MJOwfC6Nus7EwF0W7lM0ne1bnQi1iKTYI9Q 1SCx+HhMpZFipR+mcdLBx8ktlGY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=zL8WRkcZn6KbZTs1Shr2/M e1ZM0=; b=NsXAIj+cKN3fWWSbjlx5AcQl2iT3Asw4Y3fsxPMuccKSktHD1oPap4 dDu2a0Jf/3vlR6nTfO3FhCrFFfAWvFAgz/KGumN9969ox9ibDHmAeP2vTDcCcZh3 tLfPQqPNxkrcE7xk9WvlgcWnWPSBO4Rgq+hXfEt6n1KRXMEoGcua4= Received: (qmail 40905 invoked by alias); 9 Sep 2017 13:05:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 40555 invoked by uid 89); 9 Sep 2017 13:05:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Sep 2017 13:05:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4AADA8233B for ; Sat, 9 Sep 2017 15:05:44 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MDxJ4zE7vao4 for ; Sat, 9 Sep 2017 15:05:44 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 1E3D2822AA for ; Sat, 9 Sep 2017 15:05:44 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix fallout of component reordering with -fgnat-encodings=minimal Date: Sat, 09 Sep 2017 15:05:43 +0200 Message-ID: <376242711.yRPCeeyqIs@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Tested on x86_64-suse-linux, applied on the mainline. 2017-09-09 Pierre-Marie de Rodat * gcc-interface/decl.c (gnat_to_gnu_entity) : Don't generate debug info for inner record types if -fgnat-encodings=minimal (gnat_to_gnu_entity) : Use the ultimate base record type as the debug type. 2017-09-09 Pierre-Marie de Rodat * gnat.dg/debug14.adb: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 251936) +++ gcc-interface/decl.c (working copy) @@ -3308,10 +3308,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit = build_subst_list (gnat_entity, gnat_parent_type, definition); /* Set the layout of the type to match that of the parent type, - doing required substitutions. */ - copy_and_substitute_in_layout (gnat_entity, gnat_parent_type, - gnu_type, gnu_parent_type, - gnu_subst_list, debug_info_p); + doing required substitutions. If we are in minimal GNAT + encodings mode, we don't need debug info for the inner record + types, as they will be part of the embedding variant record's + debug info. */ + copy_and_substitute_in_layout + (gnat_entity, gnat_parent_type, gnu_type, gnu_parent_type, + gnu_subst_list, + debug_info_p && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL); } else { @@ -3439,7 +3443,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnu_type = make_node (RECORD_TYPE); TYPE_NAME (gnu_type) = gnu_entity_name; if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) - SET_TYPE_DEBUG_TYPE (gnu_type, gnu_base_type); + { + /* Use the ultimate base record type as the debug type. + Subtypes and derived types bring no useful + information. */ + Entity_Id gnat_debug_type = gnat_entity; + while (Etype (gnat_debug_type) != gnat_debug_type) + gnat_debug_type = Etype (gnat_debug_type); + tree gnu_debug_type + = TYPE_MAIN_VARIANT (gnat_to_gnu_type (gnat_debug_type)); + SET_TYPE_DEBUG_TYPE (gnu_type, gnu_debug_type); + } TYPE_PACKED (gnu_type) = TYPE_PACKED (gnu_base_type); TYPE_REVERSE_STORAGE_ORDER (gnu_type) = Reverse_Storage_Order (gnat_entity);