https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123302
Bug ID: 123302
Summary: Deeply nested generics cause visibility issues for
container aggregate expressions
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Take the set of files at the end of this message which contain a vector behind
4 levels of generics (also included as an attachment). Compile with:
gnatmake -gnat2022 ./controller.adb
and you should observe the following error:
controller.ads:7:04: error: instantiation error at basic_config.adb:4
controller.ads:7:04: error: "Vector" is not visible
controller.ads:7:04: error: instantiation error at basic_config.adb:4
controller.ads:7:04: error: non-visible declaration from "Config_Data_Paths" at
a-coinve.ads:60, instance at config.ads:5
Obviously Vector should be visible here. This appears to be specific to
container aggregates and high levels of nested generics, as the following cases
compile successfully:
1. The same call to My_Config.Set inside of Controller instead of Basic_Config.
2. Replacing the Set procedure with `procedure Set (Path :
Config_Data_Paths.Extended_Index) is null;`.
3. Replacing `Config_Data_Paths.Vector` with a type defined within config.ads.
4. Compiling with `gnatmake -gnat2022 ./basic_config.adb`
This has been tested on 15.2.1 and the current trunk.
The file contents to reproduce this error follows (also attached):
==> basic_config.adb <==
package body Basic_Config is
procedure Disable_Prunt is
begin
My_Config.Set (["a", "b"]);
end Disable_Prunt;
end Basic_Config;
==> basic_config.ads <==
with Config;
generic
with package My_Config is new Config;
package Basic_Config is
procedure Disable_Prunt;
end Basic_Config;
==> config.ads <==
with Ada.Containers.Indefinite_Vectors;
generic
package Config is
package Config_Data_Paths is new Ada.Containers.Indefinite_Vectors
(Positive, String);
procedure Set (Path : Config_Data_Paths.Vector) is null;
end Config;
==> controller.adb <==
package body Controller is
procedure Foo is
begin
My_Config.Set (["a", "b"]);
end Foo;
end Controller;
==> controller.ads <==
with Config;
with Basic_Config;
generic
with package My_Config is new Config (<>);
package Controller is
package My_Module_Basic_Config is new Basic_Config (My_Config);
procedure Foo;
end Controller;