diff options
author | Justin Squirek <squirek@adacore.com> | 2018-12-11 11:09:08 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-12-11 11:09:08 +0000 |
commit | ad9741234fdd5794992d151d09cd10c03b9b91ab (patch) | |
tree | bd20601f62adac3c54b9fdd3c69f481b1f116eb3 | |
parent | 3037779978033f27614b04d4b21f4ec5d4f6b7ca (diff) | |
download | gcc-ad9741234fdd5794992d151d09cd10c03b9b91ab.zip gcc-ad9741234fdd5794992d151d09cd10c03b9b91ab.tar.gz gcc-ad9741234fdd5794992d151d09cd10c03b9b91ab.tar.bz2 |
[Ada] Crash on nesting of subunits with bodies acting as specs
This patch corrects an issue whereby a set of nested subunits including
subprogram subunits acting as bodies would cause a crash when a child
subunit "withs" an ansestor in certain instances due to a mismanagment
of the scope stack.
------------
-- Source --
------------
-- w.ads
package W is
end;
-- w-b.ads
package W.B is
pragma Elaborate_Body;
end;
-- w-b.adb
with W.B.C;
package body w.B is end;
-- w-b-c.adb
with W;
procedure W.B.C is
package D is
procedure E;
end;
package body D is separate;
begin
null;
end;
-- w-b-c-d.adb
separate (W.B.C)
package body D is
procedure E is separate;
end;
-- w-b-c-d-e.adb
with W;
separate (W.B.C.D)
procedure E is
begin
null;
end;
-----------------
-- Compilation --
-----------------
$ gnatmake -q w-b.adb
2018-12-11 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_ch10.adb (Analyze_Subunit): Modify conditional to fully
remove parent contexts from library-level subprogram bodies in
addition to package bodies.
From-SVN: r266978
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9ed28c4..b190949 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-12-11 Justin Squirek <squirek@adacore.com> + + * sem_ch10.adb (Analyze_Subunit): Modify conditional to fully + remove parent contexts from library-level subprogram bodies in + addition to package bodies. + 2018-12-11 Hristian Kirtchev <kirtchev@adacore.com> * exp_prag.adb (Expand_Pragma_Initial_Condition): Do not diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 10e863f..e540299 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -2352,7 +2352,9 @@ package body Sem_Ch10 is Remove_Scope; end if; - if Nkind (Unit (Lib_Spec)) = N_Package_Body then + if Nkind_In + (Unit (Lib_Spec), N_Package_Body, N_Subprogram_Body) + then Remove_Context (Library_Unit (Lib_Spec)); end if; end if; |