The declarations of Remote_Types and Remote_Call_Interface packages are
allowed to depend on preelaborated packages, as specified in AI05-206,
as long as the dependence is made using a private with_clause. Before
this fix, the compiler was disallowing such a dependence for RCI packages,
and for Remote_Types packages it was incorrectly permitting dependence
via a normal with_clause.
The following packages must compile either quietly or with an error,
as shown below:
$ gcc -c -gnat05 rt_pkg_1.ads
rt_pkg_1.ads:1:06: must use private with clause for preelaborated unit
"Preelab_Pkg"
$ gcc -c -gnat05 rt_pkg_2.ads
[no output]
$ gcc -c -gnat05 rci_pkg_1.ads
rci_pkg_1.ads:1:06: must use private with clause for preelaborated unit
"Preelab_Pkg"
$ gcc -c -gnat05 rci_pkg_2.ads
[no output]
package Preelab_Pkg is
pragma Preelaborate;
end Preelab_Pkg;
with Preelab_Pkg; -- Should be rejected (per AI05-0206)
package RT_Pkg_1 is
pragma Remote_Types;
end RT_Pkg_1;
private with Preelab_Pkg; -- Should be accepted (per AI05-0206)
package RT_Pkg_2 is
pragma Remote_Types;
end RT_Pkg_2;
with Preelab_Pkg; -- Should be rejected (per AI05-0206)
package RCI_Pkg_1 is
pragma Remote_Call_Interface;
end RCI_Pkg_1;
private with Preelab_Pkg; -- Should be accepted (per AI05-0206)
package RCI_Pkg_2 is
pragma Remote_Call_Interface;
end RCI_Pkg_2;
Tested on x86_64-pc-linux-gnu, committed on trunk
2012-07-09 Gary Dismukes <[email protected]>
* sem_cat.adb (Check_Categorization_Dependencies):
Allow dependence of both Remote_Types and Remote_Call_Interface
declarations (not just Remote_Types units) on preelaborated
units, but require that the dependence be made via a private
with_clause. Issue a specialized error message.
Index: sem_cat.adb
===================================================================
--- sem_cat.adb (revision 189366)
+++ sem_cat.adb (working copy)
@@ -219,10 +219,14 @@
then
null;
- -- Special case: Remote_Types can depend on Preelaborated per
- -- Ada 2005 AI 0206.
+ -- Special case: Remote_Types and Remote_Call_Interface declarations
+ -- can depend on a preelaborated unit via a private with_clause, per
+ -- AI05-0206.
- elsif Unit_Category = Remote_Types
+ elsif (Unit_Category = Remote_Types
+ or else Unit_Category = Remote_Call_Interface)
+ and then (Nkind (N) = N_With_Clause
+ and then Private_Present (N))
and then Is_Preelaborated (Depended_Entity)
then
null;
@@ -263,6 +267,17 @@
then
return;
+ -- Dependence of Remote_Types or Remote_Call_Interface declaration
+ -- on a preelaborated unit with a normal with_clause.
+
+ elsif (Unit_Category = Remote_Types
+ or else Unit_Category = Remote_Call_Interface)
+ and then Is_Preelaborated (Depended_Entity)
+ then
+ Error_Msg_NE
+ ("<must use private with clause for preelaborated unit& ",
+ N, Depended_Entity);
+
-- Subunit case
elsif Is_Subunit then