This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch corrects the mechanism which determines whether a construct appears at the library level. This in turn allows for proper detection of cases where a Finalize_Storage_Only object appears in a nested scope and requires finalization. ------------ -- Source -- ------------ -- main.adb with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Main is generic package Memory_File is File : Unbounded_String; procedure Add_String (S : String); procedure Add_New_Line; end Memory_File; package body Memory_File is procedure Add_String (S : String) is begin Append (File, S); end Add_String; procedure Add_New_Line is begin Add_String (ASCII.CR & ASCII.LF); end Add_New_Line; end Memory_File; function Leak return String is package Mem is new Memory_File; use Mem; begin Add_String ("This is a test"); Add_New_Line; return To_String (File); end Leak; begin for Index in 1 .. 100 loop declare Result : String := Leak; pragma Warnings (Off, Result); begin null; end; end loop; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q main.adb -largs -lgmem $ ./main $ gnatmem ./main $ Global information $ ------------------ $ Total number of allocations : 100 $ Total number of deallocations : 100 $ Final Water Mark (non freed mem) : 0 Bytes $ High Water Mark : 48 Bytes Tested on x86_64-pc-linux-gnu, committed on trunk 2012-04-26 Hristian Kirtchev <kirtchev@adacore.com> * exp_ch7.adb (Expand_Cleanup_Actions): Update the call to Requires_Cleanup_Actions. * exp_util.adb (Requires_Cleanup_Actions (List_Id; Boolean; Boolean)): Rename formal parameter For_Package to Lib_Level to better reflect its purpose. Update the related comment and all occurrences of For_Package in the body. (Requires_Cleanup_Actions (Node_Id; Boolean)): Add new formal parameter Lib_Level. Add local constant At_Lib_Level to keep monitor whether the path taken from the top-most context to the current construct involves package constructs. Update all calls to Requires_Cleanup_Actions. * exp_util.ads (Requires_Cleanup_Actions): Add new formal parameter Lib_Level and associated comment.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |