From patchwork Mon Jun 14 09:37:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 55501 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 E4A271007D1 for ; Mon, 14 Jun 2010 19:37:56 +1000 (EST) Received: (qmail 24513 invoked by alias); 14 Jun 2010 09:37:53 -0000 Received: (qmail 24477 invoked by uid 22791); 14 Jun 2010 09:37:53 -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, 14 Jun 2010 09:37:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 311A8CB021C; Mon, 14 Jun 2010 11:37:44 +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 ucXHkynMlqVW; Mon, 14 Jun 2010 11:37:44 +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 1CD9ACB021B; Mon, 14 Jun 2010 11:37:44 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 22856D9B31; Mon, 14 Jun 2010 11:37:50 +0200 (CEST) Date: Mon, 14 Jun 2010 11:37:50 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Elaboration checks in generic units Message-ID: <20100614093750.GA3937@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 Calls within a generic unit do not need an elaboration check. This patch fixes a hole in the dynamic elaboration machinery, which allowed internal calls from a subprogram nested within a generic unit to be placed in the list of calls that are examined after semantic analysis, leading to crashes in units compiled with -gnatE. The following must compile quietly: gcc -c -gnatE p1.adb --- package P1 is generic function Gen (X : Integer) return Integer; end; --- package body P1 is function Gen (X : Integer) return Integer is function Gen2 (X: integer) return Integer is begin return Gen (X - 1); end; begin if X = 0 then return 0; else return Gen2 (X - Gen (2)); end if; end Gen; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-14 Ed Schonberg * sem_elab.adb (Check_Internal_Call): Do not place a call appearing within a generic unit in the table of delayed calls. Index: sem_elab.adb =================================================================== --- sem_elab.adb (revision 149925) +++ sem_elab.adb (working copy) @@ -1891,6 +1891,11 @@ package body Sem_Elab is elsif In_Task_Activation then return; + + -- Nothing to do if call is within a generic unit. + + elsif Inside_A_Generic then + return; end if; -- Delay this call if we are still delaying calls