From patchwork Mon Aug 29 13:48:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112055 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 CAB5CB6F8B for ; Mon, 29 Aug 2011 23:49:18 +1000 (EST) Received: (qmail 20839 invoked by alias); 29 Aug 2011 13:49:11 -0000 Received: (qmail 20790 invoked by uid 22791); 29 Aug 2011 13:49:04 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Aug 2011 13:48:50 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 712C22BAB72; Mon, 29 Aug 2011 09:48:49 -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 XHrx0o1xHbJ6; Mon, 29 Aug 2011 09:48:49 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 5942C2BAB17; Mon, 29 Aug 2011 09:48:49 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 57A1892A55; Mon, 29 Aug 2011 09:48:49 -0400 (EDT) Date: Mon, 29 Aug 2011 09:48:49 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Finalization actions in instances within generic units Message-ID: <20110829134849.GA12320@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 Instance bodies nested within generic bodies are always built, so that semantic checks can be performed on them. Finalization actions on entities within these instances must not be generated because expansion will have been disabled at various points and because finalizers are only relevant in executable code. Previously finalization actions were excluded in the context of a generic suprogram, but not a generic package body. No short example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-29 Ed Schonberg * inline.adb (Add_Scopes_To_Clean): Exclude any entity within a generic unit. Index: inline.adb =================================================================== --- inline.adb (revision 178155) +++ inline.adb (working copy) @@ -496,8 +496,10 @@ return; end if; - -- If the instance appears within a generic subprogram there is nothing - -- to finalize either. + -- If the instance is within a generic unit, no finalization code + -- can be generated. Note that at this point all bodies have been + -- analyzed, and the scope stack itself is not present, and the flag + -- Inside_A_Generic is not set. declare S : Entity_Id; @@ -505,7 +507,7 @@ begin S := Scope (Inst); while Present (S) and then S /= Standard_Standard loop - if Is_Generic_Subprogram (S) then + if Is_Generic_Unit (S) then return; end if;