From patchwork Sat Sep 9 12:09:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 811953 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-461768-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="kVCh4rNf"; 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 3xqCfS4llfz9sBW for ; Sat, 9 Sep 2017 22:09:19 +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=IBWlZaHCmfk3MUWz yH64PwQTZM0b51wdzLPJk9YDsOiJslw+Q4hagJQ4UyPItfNiuaWZTh6HZ6clNp6G UC6UifQw7luvrlHkugP/zPZQfQkSH1nuRFGWTBU3O7Xc+uU9rgD8UzmLvFLdRh3s mlQzoh5B76nV7H1AaVnGflqiaQs= 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=kGIw6uD9KVh3o35S/imian T+8l0=; b=kVCh4rNfek7f+LbJc7msXSEJXN2gRi6AA6MDJt9CrnB/jWdqFqwX5Y J8uMnO20Z3Kl/1dkVaRNeMKkfUUkkZPhaOp5TIQ76GDC1XkM2eEUFPsWMCv6rJa1 9kzSqYC5fpWXqQuU7uXlOXo3c4xO+Yki6w2Y9MsQfcyYJxCFE194Q= Received: (qmail 20860 invoked by alias); 9 Sep 2017 12:09:12 -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 20490 invoked by uid 89); 9 Sep 2017 12:09:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, 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:09:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id F0B9C822BB for ; Sat, 9 Sep 2017 14:09:05 +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 I9XfMa4IWdmw for ; Sat, 9 Sep 2017 14:09:05 +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 C182C82278 for ; Sat, 9 Sep 2017 14:09:05 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Internal error on volatile array with VFA component Date: Sat, 09 Sep 2017 14:09:05 +0200 Message-ID: <3994059.azMvNnZEZJ@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 caused by a mode mismatch between variants of the same type. Tested on x86_64-suse-linux, applied on the mainline and 7 branch. 2017-09-09 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity): Only set theTYPE_ALIGN_OK and TYPE_BY_REFERENCE_P flags on types after various promotions. * gcc-interface/trans.c (node_has_volatile_full_access): Consider all kinds of entities. 2017-09-09 Eric Botcazou * gnat.dg/specs/vfa.ads: Rename into... * gnat.dg/specs/vfa1.ads: ...this. * gnat.dg/specs/vfa2.ads: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 251906) +++ gcc-interface/decl.c (working copy) @@ -4277,18 +4277,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit already defined so we cannot pass true for IN_PLACE here. */ process_attributes (&gnu_type, &attr_list, false, gnat_entity); - /* Tell the middle-end that objects of tagged types are guaranteed to - be properly aligned. This is necessary because conversions to the - class-wide type are translated into conversions to the root type, - which can be less aligned than some of its derived types. */ - if (Is_Tagged_Type (gnat_entity) - || Is_Class_Wide_Equivalent_Type (gnat_entity)) - TYPE_ALIGN_OK (gnu_type) = 1; - - /* Record whether the type is passed by reference. */ - if (!VOID_TYPE_P (gnu_type) && Is_By_Reference_Type (gnat_entity)) - TYPE_BY_REFERENCE_P (gnu_type) = 1; - /* ??? Don't set the size for a String_Literal since it is either confirming or we don't handle it properly (if the low bound is non-constant). */ @@ -4498,17 +4486,29 @@ gnat_to_gnu_entity (Entity_Id gnat_entit /* If this is not an unconstrained array type, set some flags. */ if (TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE) { + /* Tell the middle-end that objects of tagged types are guaranteed to + be properly aligned. This is necessary because conversions to the + class-wide type are translated into conversions to the root type, + which can be less aligned than some of its derived types. */ + if (Is_Tagged_Type (gnat_entity) + || Is_Class_Wide_Equivalent_Type (gnat_entity)) + TYPE_ALIGN_OK (gnu_type) = 1; + + /* Record whether the type is passed by reference. */ + if (Is_By_Reference_Type (gnat_entity) && !VOID_TYPE_P (gnu_type)) + TYPE_BY_REFERENCE_P (gnu_type) = 1; + + /* Record whether an alignment clause was specified. */ if (Present (Alignment_Clause (gnat_entity))) TYPE_USER_ALIGN (gnu_type) = 1; + /* Record whether a pragma Universal_Aliasing was specified. */ if (Universal_Aliasing (gnat_entity) && !TYPE_IS_DUMMY_P (gnu_type)) TYPE_UNIVERSAL_ALIASING_P (gnu_type) = 1; /* If it is passed by reference, force BLKmode to ensure that objects of this type will always be put in memory. */ - if (TYPE_MODE (gnu_type) != BLKmode - && AGGREGATE_TYPE_P (gnu_type) - && TYPE_BY_REFERENCE_P (gnu_type)) + if (AGGREGATE_TYPE_P (gnu_type) && TYPE_BY_REFERENCE_P (gnu_type)) SET_TYPE_MODE (gnu_type, BLKmode); } Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 251906) +++ gcc-interface/trans.c (working copy) @@ -4075,8 +4075,6 @@ node_has_volatile_full_access (Node_Id g case N_Identifier: case N_Expanded_Name: gnat_entity = Entity (gnat_node); - if (Ekind (gnat_entity) != E_Variable) - break; return Is_Volatile_Full_Access (gnat_entity) || Is_Volatile_Full_Access (Etype (gnat_entity));