===================================================================
@@ -3035,12 +3035,12 @@ package Einfo is
-- interpreted as true. Currently this is set true for derived Boolean
-- types which have a convention of C, C++ or Fortran.
+-- No_Pool_Assigned (Flag131) [root type only] Present in access types.
+-- Set if a storage size clause applies to the variable with a static
+-- expression value of zero. This flag is used to generate errors if any
+-- attempt is made to allocate or free an instance of such an access
+-- type. This is set only in the root type, since derived types must
+-- have the same pool.
-- No_Return (Flag113)
-- Present in all entities. Always false except in the case of procedures
===================================================================
@@ -4296,15 +4296,7 @@ package body Sem_Res is
-- Check for allocation from an empty storage pool
if No_Pool_Assigned (Typ) then
- declare
- Loc : constant Source_Ptr := Sloc (N);
- begin
- Error_Msg_N ("?allocation from empty storage pool!", N);
- Error_Msg_N ("\?Storage_Error will be raised at run time!", N);
- Insert_Action (N,
- Make_Raise_Storage_Error (Loc,
- Reason => SE_Empty_Storage_Pool));
- end;
+ Error_Msg_N ("allocation from empty storage pool!", N);
-- If the context is an unchecked conversion, as may happen within
-- an inlined subprogram, the allocator is being resolved with its
===================================================================
@@ -1859,7 +1859,7 @@ package body Sem_Ch13 is
return;
end if;
- if Compile_Time_Known_Value (Expr)
+ if Is_OK_Static_Expression (Expr)
and then Expr_Value (Expr) = 0
then
Set_No_Pool_Assigned (Btype);
Ada specifies that allocation from an empty storage pool (one for which a static storage size of zero was given) is an error, but previously we were just generating a warning. This patch corrects that oversight. The following shows the new error message (compiled with -gnat05) 1. procedure BadUCnew is 2. type R is access all integer; 3. for R'Storage_Size use 0; 4. RR : R; 5. begin 6. RR := new Integer'(3); | >>> allocation from empty storage pool 7. end; Note: the patch restricts these messages to static expressions with a value of zero to correspond exactly to the language rules. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-07 Robert Dewar <dewar@adacore.com> * einfo.ads (No_Pool_Assigned): Update documentation. * sem_ch13.adb (Analyze_Attribute_Definition_Clause, case Storage_Size): We only set No_Pool_Assigned if the expression is a static constant and zero. * sem_res.adb (Resolve_Allocator): Allocation from empty storage pool should be an error not a warning.