Restrictions No_Abort_Statements and No_Dynamic_Attachment follow exactly
the RM rule which forbids any references to certain entities. But this
should not apply to the units in which these entities are declared, since
otherwise, for example, a pragma Inline for one of these entities is a
violation of this restriction. This patch avoids complaining about any
reference to restricted entities from within their own extended units.
Given a gnat.adc file containing
pragma Restrictions (No_Abort_Statements);
with this patch, you can compile s-taside.ads using -gnatc -gnatg
and the compilation does not flag a restriction violation.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-05-21 Robert Dewar <[email protected]>
* sem_util.adb (Set_Entity_With_Checks): Don't complain about
references to restricted entities within the units in which they
are declared.
Index: sem_util.adb
===================================================================
--- sem_util.adb (revision 210695)
+++ sem_util.adb (working copy)
@@ -15877,6 +15877,11 @@
if Restriction_Check_Required (No_Abort_Statements)
and then (Is_RTE (Val, RE_Abort_Task))
+
+ -- A special extra check, don't complain about a reference from within
+ -- the Ada.Task_Identification package itself!
+
+ and then not In_Same_Extended_Unit (N, Val)
then
Check_Restriction (No_Abort_Statements, Post_Node);
end if;
@@ -15892,6 +15897,10 @@
Is_RTE (Val, RE_Exchange_Handler) or else
Is_RTE (Val, RE_Detach_Handler) or else
Is_RTE (Val, RE_Reference))
+ -- A special extra check, don't complain about a reference from within
+ -- the Ada.Interrupts package itself!
+
+ and then not In_Same_Extended_Unit (N, Val)
then
Check_Restriction (No_Dynamic_Attachment, Post_Node);
end if;