]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix infinite loop with multiple limited with clauses
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 26 Sep 2023 20:54:12 +0000 (22:54 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 10 Oct 2023 12:12:28 +0000 (14:12 +0200)
commit6bd83c90191a512d2c9094623248219d610b4372
treec8496f76fb358b205fc35d3aa60742efe3b049ef
parent34992e156b6a4d737440e675b86cd2f8ac103363
ada: Fix infinite loop with multiple limited with clauses

This occurs when one of the types has an incomplete declaration in addition
to its full declaration in its package. In this case AI05-129 says that the
incomplete type is not part of the limited view of the package, i.e. only
the full view is. Now, in the GNAT implementation, it's the opposite in the
regular view of the package, i.e. the incomplete type is the visible one.

That's why the implementation needs to also swap the types on the visibility
chain while it is swapping the views when the clauses are either installed
or removed. This works correctly for the installation, but does not for the
removal, so this change rewrites the code doing the latter.

gcc/ada/
PR ada/111434
* sem_ch10.adb (Replace): New procedure to replace an entity with
another on the homonym chain.
(Install_Limited_With_Clause): Rename Non_Lim_View to Typ for the
sake of consistency.  Call Replace to do the replacements and split
the code into the regular and the special cases.  Add debuggging
output controlled by -gnatdi.
(Install_With_Clause): Print the Parent_With and Implicit_With flags
in the debugging output controlled by -gnatdi.
(Remove_Limited_With_Unit.Restore_Chain_For_Shadow (Shadow)): Rewrite
using a direct replacement of E4 by E2.   Call Replace to do the
replacements.  Add debuggging output controlled by -gnatdi.
gcc/ada/sem_ch10.adb