diff options
author | Justin Squirek <squirek@adacore.com> | 2020-05-02 17:17:24 -0400 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-17 13:14:11 -0300 |
commit | 5a6d4934a6550aa75fb4dcd59352c63f5edbbc8f (patch) | |
tree | 3be287f330f365fe37f84080e117515f6f8a6db9 /gcc | |
parent | fc59859ce2c9b93ba34bb21153ba8ea4d7de4554 (diff) | |
download | gcc-5a6d4934a6550aa75fb4dcd59352c63f5edbbc8f.zip gcc-5a6d4934a6550aa75fb4dcd59352c63f5edbbc8f.tar.gz gcc-5a6d4934a6550aa75fb4dcd59352c63f5edbbc8f.tar.bz2 |
[Ada] Crash on compiling project with multiple subunits per file
2020-06-19 Justin Squirek <squirek@adacore.com>
gcc/ada/
* lib.adb (Check_Same_Extended_Unit): Add check to determine if
the body for the subunits exist in the same file as their
specifications.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/lib.adb | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/gcc/ada/lib.adb b/gcc/ada/lib.adb index fd0f167..806f939 100644 --- a/gcc/ada/lib.adb +++ b/gcc/ada/lib.adb @@ -362,6 +362,12 @@ package body Lib is -- Step 2: Check subunits. If a subunit is instantiated, follow the -- instantiation chain rather than the stub chain. + -- Note that we must handle the case where the subunit exists in the + -- same body as the main unit (which may happen when Naming gets + -- manually specified within a project file or through tools like + -- gprname). Otherwise, we will have an infinite loop jumping around + -- the same file. + Unit1 := Unit (Cunit (Unum1)); Unit2 := Unit (Cunit (Unum2)); Inst1 := Instantiation (Sind1); @@ -384,21 +390,35 @@ package body Lib is Length_Of_Name (Unit_Name (Unum2)) then Sloc2 := Sloc (Corresponding_Stub (Unit2)); - Unum2 := Get_Source_Unit (Sloc2); - goto Continue; + if Unum2 /= Get_Source_Unit (Sloc2) then + Unum2 := Get_Source_Unit (Sloc2); + goto Continue; + else + null; -- Unum2 already designates the correct unit + end if; else Sloc1 := Sloc (Corresponding_Stub (Unit1)); - Unum1 := Get_Source_Unit (Sloc1); - goto Continue; + + if Unum1 /= Get_Source_Unit (Sloc1) then + Unum1 := Get_Source_Unit (Sloc1); + goto Continue; + else + null; -- Unum1 already designates the correct unit + end if; end if; -- Sloc1 in subunit, Sloc2 not else Sloc1 := Sloc (Corresponding_Stub (Unit1)); - Unum1 := Get_Source_Unit (Sloc1); - goto Continue; + + if Unum1 /= Get_Source_Unit (Sloc1) then + Unum1 := Get_Source_Unit (Sloc1); + goto Continue; + else + null; -- Unum1 already designates the correct unit + end if; end if; -- Sloc2 in subunit, Sloc1 not @@ -408,8 +428,13 @@ package body Lib is and then Inst2 = No_Location then Sloc2 := Sloc (Corresponding_Stub (Unit2)); - Unum2 := Get_Source_Unit (Sloc2); - goto Continue; + + if Unum2 /= Get_Source_Unit (Sloc2) then + Unum2 := Get_Source_Unit (Sloc2); + goto Continue; + else + null; -- Unum2 already designates the correct unit + end if; end if; -- Step 3: Check instances. The two locations may yield a common |