From patchwork Sat Sep 9 12:41:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 811956 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-461772-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="SzXZk6jY"; 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 3xqDMv51ynz9s5L for ; Sat, 9 Sep 2017 22:41:45 +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=uNczKDvbortJjdGF rmQIEbfvU8L7+xP8NuMNftlVW95UEw8GGfyuyrRCtegxiCh/RC4/O7UQ7vt/iKFW 1yLMw4EPsmsf2bkTNGT7ERFEuvC9kJ8ERWokNIwV4xWj8EWllZ/q7+SP/T287iS4 VlmRQuaJSw9WXliPp5Vs5R/LXQk= 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=lboF4ZOfd7kvRJDZ2vihwS 09rL4=; b=SzXZk6jYsB8Q5rM0H1QxdUj7boGIEiRV/ZE8NRaCslc3gULtTD5BAz frtw75phmiOU6nCz701D/MjPZCyDfWWZzqzcksq4LXwduUQ65psEs2D0Ijf8EsP7 uBhIvOtyGAmNUBQk/b/WUlE4Jbbt7i8B/T7AUjYLHzT/BkWDg/cKo= Received: (qmail 109544 invoked by alias); 9 Sep 2017 12:41:34 -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 109020 invoked by uid 89); 9 Sep 2017 12:41:33 -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 12:41:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id AC53B822F6 for ; Sat, 9 Sep 2017 14:41:29 +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 L1nCA-ARliEA for ; Sat, 9 Sep 2017 14:41:29 +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 7F5E781DD3 for ; Sat, 9 Sep 2017 14:41:29 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix wrong derivation of record type into unchecked union Date: Sat, 09 Sep 2017 14:41:28 +0200 Message-ID: <2258439.f4HttFnXHJ@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 It's a fallout of the new implementation of layout for derived record types. Tested on x86_64-suse-linux, applied on the mainline. 2017-09-09 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Copy the layout of the record from the parent type only if both are or are not unchecked unions. (is_stored_discriminant): Return false for an unchecked union. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 251931) +++ gcc-interface/decl.c (working copy) @@ -3287,15 +3287,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } /* If this is a derived type with discriminants and these discriminants - affect the initial shape it has inherited, factor them in. But for - an Unchecked_Union (it must be an Itype), just process the type. */ + affect the initial shape it has inherited, factor them in. */ if (has_discr && !is_extension && !Has_Record_Rep_Clause (gnat_entity) && Stored_Constraint (gnat_entity) != No_Elist && (gnat_parent_type = Underlying_Type (Etype (gnat_entity))) && Is_Record_Type (gnat_parent_type) - && !Is_Unchecked_Union (gnat_parent_type) + && Is_Unchecked_Union (gnat_entity) + == Is_Unchecked_Union (gnat_parent_type) && No_Reordering (gnat_entity) == No_Reordering (gnat_parent_type)) { tree gnu_parent_type @@ -9328,7 +9328,9 @@ copy_and_substitute_in_size (tree new_ty static inline bool is_stored_discriminant (Entity_Id discr, Entity_Id record_type) { - if (Is_Tagged_Type (record_type)) + if (Is_Unchecked_Union (record_type)) + return false; + else if (Is_Tagged_Type (record_type)) return No (Corresponding_Discriminant (discr)); else if (Ekind (record_type) == E_Record_Type) return Original_Record_Component (discr) == discr;