diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-09-19 08:14:08 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-09-19 08:14:08 +0000 |
commit | 46fa6b050e81504aab992d58b693aa81dd45eeb9 (patch) | |
tree | ec318c027eeff071e8ac3c903adcdd563a59a78b /gcc/ada/sem_ch7.adb | |
parent | 231ef54b96d6022bc844107f50490ba5c96f4a50 (diff) | |
download | gcc-46fa6b050e81504aab992d58b693aa81dd45eeb9.zip gcc-46fa6b050e81504aab992d58b693aa81dd45eeb9.tar.gz gcc-46fa6b050e81504aab992d58b693aa81dd45eeb9.tar.bz2 |
[Ada] Spurious visibility error in generic child unit
2019-09-19 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch7.adb (Install_Parent_Private_Declarations): If a
generic child unit is instantiated within a sibling child unit,
the analysis of its private part requires that the private part
of the ancestor be available, as is done when the context
includes an instance of the ancestor.
gcc/testsuite/
* gnat.dg/generic2-child.ads, gnat.dg/generic2-io_any.adb,
gnat.dg/generic2-io_any.ads, gnat.dg/generic2.ads: New testcase.
From-SVN: r275949
Diffstat (limited to 'gcc/ada/sem_ch7.adb')
-rw-r--r-- | gcc/ada/sem_ch7.adb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index f7998c0..db6bffd 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1508,9 +1508,21 @@ package body Sem_Ch7 is Inst_Par := Renamed_Entity (Inst_Par); end if; - Gen_Par := - Generic_Parent - (Specification (Unit_Declaration_Node (Inst_Par))); + -- The instance may appear in a sibling generic unit, in + -- which case the prefix must include the common (generic) + -- ancestor, which is treated as a current instance. + + if Inside_A_Generic + and then Ekind (Inst_Par) = E_Generic_Package + then + Gen_Par := Inst_Par; + pragma Assert (In_Open_Scopes (Gen_Par)); + + else + Gen_Par := + Generic_Parent + (Specification (Unit_Declaration_Node (Inst_Par))); + end if; -- Install the private declarations and private use clauses -- of a parent instance of the child instance, unless the |