From patchwork Tue Sep 5 09:22:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 810029 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-461468-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="RztQvqwI"; 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 3xmh8R1Y3Gz9sPt for ; Tue, 5 Sep 2017 19:23:02 +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=SLoMWhDd4KoJNFeF EAIn7sDML2oCgaCIAL+hQUyW6sD6ulRJvivokvZThX/bdMT1syOLMetU6o53dwu6 vxaBz0RwAyUY78gb/EEtJnJxn2sJcqu2UZ86KLozjmlj8emloWCPQuc4Hpz70n8i RbGQd+W3OHqtxlWcyVkGkQv4Y60= 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=z/OnBCviVsknPJgLL3lwUv fR460=; b=RztQvqwIiDdI2Af9wbNXdCevIanj+cD4gkPVZ/4FSA1hjv6ud74izO tV7lmLIY/kujP6y2Sq8mLCz9IUcd1r3mMwA4KqNu7B6Wu0zlqFM0tVlWDmJXmAP7 NRLElsi3UHe1s6eiDvLlFkuwNNI7quofVSstq0HyQekRJ0VwUSchU= Received: (qmail 31622 invoked by alias); 5 Sep 2017 09:22:52 -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 31609 invoked by uid 89); 5 Sep 2017 09:22:51 -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=Hx-languages-length:1333, contrary 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; Tue, 05 Sep 2017 09:22:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 47BE0822CA for ; Tue, 5 Sep 2017 11:22: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 i_R5wp5-qbtY for ; Tue, 5 Sep 2017 11:22: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 249C082266 for ; Tue, 5 Sep 2017 11:22:44 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix bogus constraint error on value conversion with -gnatVa Date: Tue, 05 Sep 2017 11:22:33 +0200 Message-ID: <3137505.kkK2uPGjte@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 mainline. 2017-09-05 Eric Botcazou * gcc-interface/trans.c (Attribute_to_gnu) : Do notstrip conversions around prefixes that are not references. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 251700) +++ gcc-interface/trans.c (working copy) @@ -1629,10 +1629,14 @@ Attribute_to_gnu (Node_Id gnat_node, tre case Attr_Address: case Attr_Unrestricted_Access: - /* Conversions don't change addresses but can cause us to miss the - COMPONENT_REF case below, so strip them off. */ - gnu_prefix = remove_conversions (gnu_prefix, - !Must_Be_Byte_Aligned (gnat_node)); + /* Conversions don't change the address of references but can cause + build_unary_op to miss the references below, so strip them off. + On the contrary, if the address-of operation causes a temporary + to be created, then it must be created with the proper type. */ + gnu_expr = remove_conversions (gnu_prefix, + !Must_Be_Byte_Aligned (gnat_node)); + if (REFERENCE_CLASS_P (gnu_expr)) + gnu_prefix = gnu_expr; /* If we are taking 'Address of an unconstrained object, this is the pointer to the underlying array. */