This patch adds a missing case to the mechanism that outputs the
elaboration order dependencies of units.
------------
-- Source --
------------
-- pack.ads
package Pack is
procedure Force_Body;
end Pack;
-- pack.adb
package body Pack is
procedure Force_Body is null;
end Pack;
-- main.adb
with Pack;
procedure Main is begin null; end Main;
----------------------------
-- Compilation and output --
----------------------------
$ gnatmake -q main.adb -bargs -e
ELABORATION ORDER DEPENDENCIES
unit "pack (spec)" must be elaborated before unit "main (body)"
reason: unit "main (body)" has with clause for unit "pack (spec)"
unit "pack (spec)" must be elaborated before unit "pack (body)"
reason: spec must be elaborated before body
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-07-11 Hristian Kirtchev <kirtc...@adacore.com>
gcc/ada/
* bindo.adb: Remove the documentation of switch -d_N because it
is no longer in use.
* bindo-graphs.ads, bindo-graphs.adb (Is_Spec_Before_Body_Edge):
New routine.
* bindo-writers.adb (Write_Dependency_Edge): Add the missing
case of a spec-before-body edge.
--- gcc/ada/bindo-graphs.adb
+++ gcc/ada/bindo-graphs.adb
@@ -4183,6 +4183,21 @@ package body Bindo.Graphs is
return U_Rec.Utype = Is_Spec or else U_Rec.Utype = Is_Spec_Only;
end Is_Spec;
+ ------------------------------
+ -- Is_Spec_Before_Body_Edge --
+ ------------------------------
+
+ function Is_Spec_Before_Body_Edge
+ (G : Library_Graph;
+ Edge : Library_Graph_Edge_Id) return Boolean
+ is
+ begin
+ pragma Assert (Present (G));
+ pragma Assert (Present (Edge));
+
+ return Kind (G, Edge) = Spec_Before_Body_Edge;
+ end Is_Spec_Before_Body_Edge;
+
-----------------------
-- Is_Spec_With_Body --
-----------------------
--- gcc/ada/bindo-graphs.ads
+++ gcc/ada/bindo-graphs.ads
@@ -1166,6 +1166,13 @@ package Bindo.Graphs is
pragma Inline (Is_Spec);
-- Determine whether vertex Vertex of library graph G denotes a spec
+ function Is_Spec_Before_Body_Edge
+ (G : Library_Graph;
+ Edge : Library_Graph_Edge_Id) return Boolean;
+ pragma Inline (Is_Spec_Before_Body_Edge);
+ -- Determine whether edge Edge of library graph G links a predecessor
+ -- spec and a successor body belonging to the same unit.
+
function Is_Spec_With_Body
(G : Library_Graph;
Vertex : Library_Graph_Vertex_Id) return Boolean;
--- gcc/ada/bindo-writers.adb
+++ gcc/ada/bindo-writers.adb
@@ -610,6 +610,11 @@ package body Bindo.Writers is
& "elaboration time",
Info => True);
+ elsif Is_Spec_Before_Body_Edge (G, Edge) then
+ Error_Msg_Output
+ (Msg => " reason: spec must be elaborated before body",
+ Info => True);
+
else
pragma Assert (Is_With_Edge (G, Edge));
--- gcc/ada/bindo.adb
+++ gcc/ada/bindo.adb
@@ -347,13 +347,9 @@ package body Bindo is
-- GNATbind outputs the library graph in textual format to standard
-- output.
--
- -- -d_N New bindo order
- --
- -- GNATbind utilizes the new bindo elaboration order
- --
-- -d_P Output cycle paths
--
- -- GNATbind output the cycle paths in text format to standard output
+ -- GNATbind outputs the cycle paths in text format to standard output
--
-- -d_S Output elaboration-order status information
--