From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58571 invoked by alias); 2 Mar 2015 11:20:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58547 invoked by uid 89); 2 Mar 2015 11:20:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_20 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; Mon, 02 Mar 2015 11:20:42 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DBB301165E7; Mon, 2 Mar 2015 06:20:40 -0500 (EST) 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 BDaKdXM6TEcQ; Mon, 2 Mar 2015 06:20:40 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id C85A41165E2; Mon, 2 Mar 2015 06:20:40 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id C45A691A8C; Mon, 2 Mar 2015 06:20:40 -0500 (EST) Date: Mon, 02 Mar 2015 11:20:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Compiler hang with full inlining and use clause in parent private part Message-ID: <20150302112040.GA1211@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-03/txt/msg00052.txt.bz2 --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2053 When compiling a descendant instance unit use_clauses in parent units are chained to simplify removal at end of compilation. Use_clauses that appear in the private part of parent are chained when compiling the private part of the descendant. To prevent circularities in the list, use_clauses in the private part of an ancestor should not be chained if there is an intervening parent whose private part is already installed. The following must compile properly: gcc -c -gnatn2 main.adbo --- with P2; with P3; package body Main is package P2_Instance is new P2.Instance (Boolean); end; --- package Main is pragma Elaborate_Body; end; --- package G1 is generic package Instance is end; end; --- generic package G2.Child is end; package body G2 is procedure P is begin null; end; end; --- generic package G2 is procedure P; pragma Inline (P); end; --- with G2.Child; package P1.G2_Instance.Child_Instance is new P1.G2_Instance.Child; --- with G2; package P1.G2_Instance is new G2; --- with G1; package P1 is private package G1_Instance is new G1.Instance; use G1_Instance; end; --- with P1.G2_Instance; package body P2 is package body Instance is procedure R (X : T_Access) is begin null; end; end Instance; end; --- package P2 is generic type T is private; package Instance is type T_Access is access all T; procedure R (X : T_Access); end Instance; end; --- with P1.G2_Instance.Child_Instance; package body P3 is end; --- with S; package P3 is pragma Elaborate_Body; function F (S : Boolean) return Integer is (0); function F (I : Integer) return Integer is (F(S.G(I))); end; --- package S is function G (I : Integer) return Boolean; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-03-02 Ed Schonberg * sem_ch8.adb (Chain_Use_Clause): Do not chain use clause from ancestor to list of use clauses active in descendant unit if we are within the private part of an intervening parent, to prevent circularities in use clause list. --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 660 Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 221113) +++ sem_ch8.adb (working copy) @@ -4026,6 +4026,15 @@ if not In_Open_Scopes (Pack) then null; -- default as well + -- If the use clause appears in an ancestor and we are in the + -- private part of the immediate parent, the use clauses are + -- already installed. + + elsif Pack /= Scope (Current_Scope) + and then In_Private_Part (Scope (Current_Scope)) + then + null; + else -- Find entry for parent unit in scope stack --3MwIy2ne0vdjdPXF--