diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-01-24 11:58:35 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-04 05:11:08 -0400 |
commit | c21938bee0d0a5cb3da442d3d4500d2eeb416b44 (patch) | |
tree | 8d5d54dd0c83c1af229c5e08097b8d17e4d09ed6 /gcc/ada/sem.adb | |
parent | 1e01dddb44e051224239d44f6042a379cbf583ab (diff) | |
download | gcc-c21938bee0d0a5cb3da442d3d4500d2eeb416b44.zip gcc-c21938bee0d0a5cb3da442d3d4500d2eeb416b44.tar.gz gcc-c21938bee0d0a5cb3da442d3d4500d2eeb416b44.tar.bz2 |
[Ada] Wrong walk order in Walk_Library_Items
2020-06-04 Arnaud Charlet <charlet@adacore.com>
gcc/ada/
* sem.adb (Walk_Library_Items): Defer processing of main spec
after all other specs and before processing bodies.
Diffstat (limited to 'gcc/ada/sem.adb')
-rw-r--r-- | gcc/ada/sem.adb | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index e52667f..2c5c54b 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -1673,6 +1673,7 @@ package body Sem is pragma Pack (Unit_Number_Set); Main_CU : constant Node_Id := Cunit (Main_Unit); + Spec_CU : Node_Id := Empty; Seen, Done : Unit_Number_Set := (others => False); -- Seen (X) is True after we have seen unit X in the walk. This is used @@ -2146,27 +2147,43 @@ package body Sem is null; when others => - Par := Scope (Defining_Entity (Unit (CU))); - - if Is_Child_Unit (Defining_Entity (Unit (CU))) then - while Present (Par) - and then Par /= Standard_Standard - and then Par /= Cunit_Entity (Main_Unit) - loop - Par := Scope (Par); - end loop; - end if; - if Par /= Cunit_Entity (Main_Unit) then - Do_Unit_And_Dependents (CU, N); - end if; + -- Skip spec of main unit for now, we want to process it + -- after all other specs. + + if Nkind (Unit (CU)) = N_Package_Declaration + and then Library_Unit (CU) = Main_CU + and then CU /= Main_CU + then + Spec_CU := CU; + else + Par := Scope (Defining_Entity (Unit (CU))); + + if Is_Child_Unit (Defining_Entity (Unit (CU))) then + while Present (Par) + and then Par /= Standard_Standard + and then Par /= Cunit_Entity (Main_Unit) + loop + Par := Scope (Par); + end loop; + end if; + if Par /= Cunit_Entity (Main_Unit) then + Do_Unit_And_Dependents (CU, N); + end if; + end if; end case; end; Next_Elmt (Cur); end loop; + -- Now process main package spec if skipped + + if Present (Spec_CU) then + Do_Unit_And_Dependents (Spec_CU, Unit (Spec_CU)); + end if; + -- Now process package bodies on which main depends, followed by bodies -- of parents, if present, and finally main itself. |