From patchwork Mon Oct 18 09:46:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 68153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E2772B70DF for ; Mon, 18 Oct 2010 20:46:48 +1100 (EST) Received: (qmail 15970 invoked by alias); 18 Oct 2010 09:46:46 -0000 Received: (qmail 15960 invoked by uid 22791); 18 Oct 2010 09:46:45 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Oct 2010 09:46:40 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 669F9CB025B; Mon, 18 Oct 2010 11:46:38 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FGT75uCbiqSp; Mon, 18 Oct 2010 11:46:38 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 3B0E5CB0254; Mon, 18 Oct 2010 11:46:38 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 1EFA5D9BB4; Mon, 18 Oct 2010 11:46:38 +0200 (CEST) Date: Mon, 18 Oct 2010 11:46:38 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Use clauses and use_type clauses Message-ID: <20101018094638.GA13921@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 When leaving the scope of a use_package clause, there may be operators declared in the package that remain use visible because a prior use_type clause is still active. The following must compile quietly: with System.Storage_Elements; procedure P is use type System.Storage_Elements.Storage_Offset; procedure P1 (X : in out System.Address) is use System.Storage_Elements; begin X := X + 1; end P1; procedure P2 (X : in out System.Address) is begin X := X + 1; end P2; begin null; end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-18 Ed Schonberg * sem_ch8.adb (Is_Primitive_Operator_In_Use): Renamed from Is_Primitive_Operator. When ending the scope of a use package scope, a primitive operator remains in use if the base type has a current use (type) clause. Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 165610) +++ sem_ch8.adb (working copy) @@ -3361,24 +3361,25 @@ package body Sem_Ch8 is Id : Entity_Id; Elmt : Elmt_Id; - function Is_Primitive_Operator + function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean; -- Check whether Op is a primitive operator of a use-visible type - --------------------------- - -- Is_Primitive_Operator -- - --------------------------- + ---------------------------------- + -- Is_Primitive_Operator_In_Use -- + ---------------------------------- - function Is_Primitive_Operator + function Is_Primitive_Operator_In_Use (Op : Entity_Id; F : Entity_Id) return Boolean is T : constant Entity_Id := Etype (F); begin - return In_Use (T) + return (In_Use (T) + or else Present (Current_Use_Clause (Base_Type (T)))) and then Scope (T) = Scope (Op); - end Is_Primitive_Operator; + end Is_Primitive_Operator_In_Use; -- Start of processing for End_Use_Package @@ -3409,11 +3410,12 @@ package body Sem_Ch8 is if Nkind (Id) = N_Defining_Operator_Symbol and then - (Is_Primitive_Operator (Id, First_Formal (Id)) + (Is_Primitive_Operator_In_Use + (Id, First_Formal (Id)) or else (Present (Next_Formal (First_Formal (Id))) and then - Is_Primitive_Operator + Is_Primitive_Operator_In_Use (Id, Next_Formal (First_Formal (Id))))) then null;