]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/ada/ChangeLog
[Ada] Spurious error on nested instantiation
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:07:18 +0000 (08:07 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:07:18 +0000 (08:07 +0000)
commitdb3b1a4760bdc70e4b06578c187f80df13306242
treeca59335f2e7442884a652520b533a5e973a44d5c
parent175b42e6edba5a5c57ef02239f77ec4a423e2f2a
[Ada] Spurious error on nested instantiation

This fixes a spurious error given by the compiler for a call to a
subprogram which is the formal subprogram parameter of a generic
package, if the generic package is instantiated in the body of an
enclosing generic package with two formal types and two formal
subprogram parameter homonyms taking them, and this instantiation takes
one the two formal types as actual, and the enclosing generic package is
instantiated on the same actual type with a single actual subprogram
parameter, and the aforementioned call is overloaded.

In this case, the renaming generated for the actual subprogram parameter
in the nested instantiation is ambiguous and must be disambiguated using
the corresponding formal parameter of the enclosing instantiation,
otherwise a (sub)type mismatch is created and later subprogram
disambiguation is not really possible.

2019-08-13  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch4.adb (Analyze_One_Call): Remove bypass for type
mismatch in nested instantiations.
* sem_ch8.adb (Find_Nearer_Entity): New function.
(Find_Renamed_Entity): Use it to disambiguate the candidates for
the renaming generated for an instantiation when it is
ambiguous.

gcc/testsuite/

* gnat.dg/generic_inst9.adb, gnat.dg/generic_inst9.ads,
gnat.dg/generic_inst9_pkg1-operator.ads,
gnat.dg/generic_inst9_pkg1.ads, gnat.dg/generic_inst9_pkg2.adb,
gnat.dg/generic_inst9_pkg2.ads: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274343 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch8.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/generic_inst9.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst9.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst9_pkg1-operator.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst9_pkg1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst9_pkg2.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst9_pkg2.ads [new file with mode: 0644]