References to allocators, just like references to volatile objects, are
now rejected in all context restricted by SPARK, both within actual
parameters and outside of them.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch4.adb (Analyze_Allocator): Reject allocators in
restricted contexts.
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -889,6 +889,16 @@ package body Sem_Ch4 is
Check_Restriction (No_Local_Allocators, N);
end if;
+ if SPARK_Mode = On
+ and then Comes_From_Source (N)
+ and then not Is_OK_Volatile_Context (Context => Parent (N),
+ Obj_Ref => N,
+ Check_Actuals => False)
+ then
+ Error_Msg_N
+ ("allocator cannot appear in this context (SPARK RM 7.1.3(10))", N);
+ end if;
+
if Serious_Errors_Detected > Sav_Errs then
Set_Error_Posted (N);
Set_Etype (N, Any_Type);