From patchwork Tue Oct 9 15:09:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 981352 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-487208-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mjvLTuL/"; 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 42V0xt46w2z9s55 for ; Wed, 10 Oct 2018 02:09:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=BFkyCfjRogVa66VHJ0S/yl9pDn+bf40dbO4IEDnI5POtPsvGCT hvbEJ4ah6yD4s+mFCMK2DT/IRoTp+YTEXe1UB7SLNz5kueud32daeGifv/00N4J7 WbITPvpXks3LX74+J8o0EkWn2TfoqKAj0k3KNLQ6u0jJQw+0Jwy7gXxJE= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=lKZUyctiekYAih2bAtvo2Hkj2+Y=; b=mjvLTuL/zm38nDTKxCSE MbwRfbM4k5HODPoKEutvxBBsMcowp5dFBZElPXHTx4NcKlPD1bzjT8l5sjHOFZ3a Qo4lschA8VeKWhh7JD1KmLME5oJaQKzGsVlVBiK+PXPwfwFqBOZ6ZT1ZTRE9ZW8w 48epSIfChUCuwnpqhw3BP3Q= Received: (qmail 27830 invoked by alias); 9 Oct 2018 15:09:14 -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 27821 invoked by uid 89); 9 Oct 2018 15:09:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Oct 2018 15:09:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A202956013; Tue, 9 Oct 2018 11:09:10 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4-G64CE7kcjd; Tue, 9 Oct 2018 11:09:10 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 8A26556012; Tue, 9 Oct 2018 11:09:10 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 8613A34B3; Tue, 9 Oct 2018 11:09:10 -0400 (EDT) Date: Tue, 9 Oct 2018 11:09:10 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious error message on visibiliy change in aspect expression Message-ID: <20181009150910.GA123269@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch removes an improper error message on a visibility change in an aspect expression between the freeze point and the end of the declaration list, when the expression involves a call to a instance of Unchecked_Conversion and the enclosing package declaration has a package body with multiple subprogram bodies. The following must compile quietly: ---- package body Par.Rep is procedure Nothing is begin null; end; procedure Rien is begin null; end; end; ---- with Par.Loc; package Par.Rep is type Rec is record X, Y : Integer; end record with Volatile; Thing2 : Unsigned_32 := 15; Thing3 : Rec with Volatile, Address => To_Address (Par.Loc.Flash_Base); procedure Nothing; end; ---- pragma Restrictions (No_Elaboration_Code); with interfaces; use interfaces; pragma unreferenced (interfaces); with Tp; use Tp; pragma unreferenced (Tp); package Par is end Par; ---- with Ada.Unchecked_Conversion; with System; with Interfaces; use Interfaces; package Tp is subtype system_address is unsigned_32; function to_address is new ada.unchecked_conversion (system_address, system.address); function To_32 is new ada.unchecked_conversion (System.Address, System_Address); end; ---- with TP; use TP; package Par.Loc is FLASH_BASE : constant system_address := 16#0800_0000#; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2018-10-09 Ed Schonberg gcc/ada/ * sem_ch6.adb (Fully_Conformant_Expressions): Handle properly the conformance check on an aspect expression that includes a call to an instance of Unchecked_Conversion, or more generally a call to an intrinsic operation. --- gcc/ada/sem_ch6.adb +++ gcc/ada/sem_ch6.adb @@ -8932,7 +8932,17 @@ package body Sem_Ch6 is or else (Chars (Entity (E1)) = Chars (Entity (E2)) and then Ekind (Entity (E1)) = E_Loop_Parameter - and then Ekind (Entity (E2)) = E_Loop_Parameter); + and then Ekind (Entity (E2)) = E_Loop_Parameter) + + -- A call to an instantiation of Unchecked_Conversion is + -- rewritten with the name of the generated function + -- created for the instance, and this must be special-cased. + + or else + (Ekind (Entity (E1)) = E_Function + and then Is_Intrinsic_Subprogram (Entity (E1)) + and then Is_Generic_Instance (Entity (E1)) + and then Entity (E2) = Alias (Entity (E1))); elsif Nkind (E1) = N_Expanded_Name and then Nkind (E2) = N_Expanded_Name