From patchwork Fri Aug 1 10:23:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 375697 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AEE611400D7 for ; Fri, 1 Aug 2014 20:23:38 +1000 (EST) 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=VQb6NVnlZdFjEqimxiDVn94XcvBrJL0BZyrnamhktr3Ylo8Ukz s18EYdXKtHuTZMzETb0FYYUtkY54TiItEhwJQnITTZaymRY0Rqm5hPcoxeW9j6+K 4+TcsNImjS09q8nddDFhBpauQfNf3rnOgXDUJqm//xNqq0zJKMGFgX35g= 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=ceE8bHmmv0Wki0TRxUyPPIoDeHc=; b=QHMKjbBVyygeHlOZKnVx /X8Vkmfe4/fyfpeSZRu4ZgK7Ph9pvL4va92OGqDYVjgJ9nMY0xQo+3fyLiWy34SM sdV/6IYu7oclvrT0XaKPtwEDGGGn8Xb9QhqfpXN7LeQE5Vd5Ce1G8aEK1e4gA/Vf Stya4f37qfcSP4HHrRvsoyk= Received: (qmail 25492 invoked by alias); 1 Aug 2014 10:23:31 -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 25471 invoked by uid 89); 1 Aug 2014 10:23:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 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 (AES256-SHA encrypted) ESMTPS; Fri, 01 Aug 2014 10:23:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 395C9116368; Fri, 1 Aug 2014 06:23:28 -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 2V810c1mYeo3; Fri, 1 Aug 2014 06:23:28 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [IPv6:2620:20:4000:0:a6ba:dbff:fe26:1f63]) by rock.gnat.com (Postfix) with ESMTP id 29F6F11635B; Fri, 1 Aug 2014 06:23:28 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 273973FE21; Fri, 1 Aug 2014 06:23:28 -0400 (EDT) Date: Fri, 1 Aug 2014 06:23:28 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious warning on generated with_clause for renamed unit Message-ID: <20140801102328.GA8468@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) This patch suppresses spurious warnings that may be generated when the prefix of a with_clause for a child unit denotes the renaming of a parent unit. Such renamings generate internal with_clauses that are not marked Implicit_With because they must be properly installed as part of the context, but they are never redundant with explicit with_clauses. The following must compile quietly: gcc -c -gnatwa pkg_b2.adb --- with Renamed_Pkg_A; package Pkg_B2 is procedure Proc_1( Val_1 : in out Renamed_Pkg_A.Type_A ); end Pkg_B2; --- package Pkg_A is type Type_A is ( A1, A2 ); end Pkg_A; --- with Pkg_A; package Renamed_Pkg_A renames Pkg_A; --- package Pkg_A.Child_A is type Type_B is ( B1, B2 ); end Pkg_A.Child_A; --- with Renamed_Pkg_A.Child_A; package body Pkg_B2 is use type Renamed_Pkg_A.Child_A.Type_B; Val_B : Renamed_Pkg_A.Child_A.Type_B := Renamed_Pkg_A.Child_A.Type_B'First; procedure Proc_1( Val_1 : in out Renamed_Pkg_A.Type_A ) is begin if Val_B = Renamed_Pkg_A.Child_A.Type_B'First then Val_1 := Renamed_Pkg_A.Type_A'Last; Val_B := Renamed_Pkg_A.Child_A.Type_B'Last; else Val_B := Renamed_Pkg_A.Child_A.Type_B'First; end if; end Proc_1; end Pkg_B2; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-08-01 Ed Schonberg * sem_ch10.adb (Analyze_Compilation_Unit): Do not place a warning on a with_clause created for the renaming of a parent unit in an explicit with_clause. Index: sem_ch10.adb =================================================================== --- sem_ch10.adb (revision 213440) +++ sem_ch10.adb (working copy) @@ -242,7 +242,7 @@ -- on the context. Note that in contrast with the handling of private -- types, the limited view and the non-limited view of a type are treated -- as separate entities, and no entity exchange needs to take place, which - -- makes the implementation must simpler than could be feared. + -- makes the implementation much simpler than could be feared. ------------------------------ -- Analyze_Compilation_Unit -- @@ -507,11 +507,15 @@ -- Avoid checking implicitly generated with clauses, limited with -- clauses or withs that have pragma Elaborate or Elaborate_All. + -- With_clauses introduced for renamings of parent clauses are not + -- marked implicit because they need to be properly installed, but + -- they do not come from source and do not require warnings. if Nkind (Clause) = N_With_Clause and then not Implicit_With (Clause) and then not Limited_Present (Clause) and then not Elaborate_Present (Clause) + and then Comes_From_Source (Clause) then -- Package body-to-spec check