]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix bogus error on limited with clause and private parent package
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 8 Nov 2025 18:15:46 +0000 (19:15 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Sat, 8 Nov 2025 18:17:34 +0000 (19:17 +0100)
commiteebee8f21d727231cf3db837684cb6cafb066fb0
treeb95e6b6e93da59b5b04f5c08ae70b5a0af88edcf
parent191896c993b1ba23dba0d0babbf8d1a043de2bd3
Ada: Fix bogus error on limited with clause and private parent package

The implementation of the 10.1.2(8/2-11/2) subclauses that establish rules
for the legality of "with" clauses of private child units is done separately
for regular "with" clauses (in Check_Private_Child_Unit) and for limited
"with" clauses (in Check_Private_Limited_Withed_Unit).  The testcase, which
contains the regular and the "limited" version of the same pattern, exhibits
a disagreement between them; the former implementation is correct and the
latter is wrong in this case.

The patch fixes the problem and also cleans up the latter implementation by
aligning it with the former as much as possible.

gcc/ada/
PR ada/34374
* sem_ch10.adb (Check_Private_Limited_Withed_Unit): Use a separate
variable for the private child unit, streamline the loop locating
the nearest private ancestor, fix a too early termination of the
loop traversing the ancestor of the current unit, and use the same
privacy test as Check_Private_Child_Unit.

gcc/testsuite/
* gnat.dg/specs/limited_with4.ads: Rename to...
* gnat.dg/specs/limited_with1.ads: ...this.
* gnat.dg/specs/limited_with4_pkg.ads: Rename to...
* gnat.dg/specs/limited_with1_pkg.ads: ...this.
* gnat.dg/specs/limited_with2-child1.ads: New test.
* gnat.dg/specs/limited_with2-child2.ads: Likewise.
* gnat.dg/specs/limited_with2.ads: New helper.
gcc/ada/sem_ch10.adb
gcc/testsuite/gnat.dg/specs/limited_with1.ads [moved from gcc/testsuite/gnat.dg/specs/limited_with4.ads with 73% similarity]
gcc/testsuite/gnat.dg/specs/limited_with1_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/limited_with2-child1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/limited_with2-child2.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/limited_with2.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/limited_with4_pkg.ads [deleted file]