diff mbox

[Ada] Finalization actions in instances within generic units

Message ID 20110829134849.GA12320@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 29, 2011, 1:48 p.m. UTC
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  <schonberg@adacore.com>

	* inline.adb (Add_Scopes_To_Clean): Exclude any entity within a generic
	unit.
diff mbox

Patch

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;