Compiling test.adb results in
test.adb:7:04: instantiation error at foo.adb:10
test.adb:7:04: "S_Two" is not visible
test.adb:7:04: instantiation error at foo.adb:10
test.adb:7:04: non-visible declaration at xy-z.ads:4
test.adb:7:04: instantiation error at foo.adb:10
test.adb:7:04: non-visible declaration at s_x-z.ads:6
even though S_Two should be perfectly visible.
Uncommenting the indicated line in foo.adb "fixes" the problem.
This error occurs with various versions of gnat and gcc.
Anyhow:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared
--with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
command line: gcc-4.0 -c test.adb
And here the files:
--- x.ads
package X is
type XX is new Integer;
procedure One(N: in out XX);
end X;
--- x.adb
package body X is
procedure One(N: in out XX) is
begin
N := 1;
end One;
end X;
--- x-z.ads
package X.Z is
procedure Two(N: in out XX);
end X.Z;
--- x-z.adb
package body X.Z is
procedure Two(N: in out XX) is
begin
N := 2;
end Two;
end X.Z;
--- s_x.ads
with X;
use X;
package S_X is
subtype XX is X.XX;
procedure S_One(N: in out XX) renames One;
end S_X;
--- s_x-z.ads
with X.Z;
use X.Z;
package S_X.Z is
procedure S_Two(N: in out XX) renames Two;
end S_X.Z;
--- xy.ads
generic
type Number is private;
with procedure S_One(N: in out Number) is <>;
package XY is
procedure One(N: in out Number) renames S_One;
end XY;
--- xy-z.ads
generic
with procedure S_Two(N: in out Number) is <>;
package XY.Z is
procedure Two(N: in out Number) renames S_Two;
end XY.Z;
--- foo.ads
generic
M: in Integer;
package Foo is
procedure Three(K: in out Integer);
end Foo;
--- foo.adb
with S_X, S_X.Z, XY, XY.Z;
use S_X, S_X.Z;
package body Foo is
-- use S_X.Z; -- uncommenting this "fixes" the problem
package Numbers is new XY (Number => XX);
use Numbers;
package Numbers_Z is new Numbers.Z;
procedure Three(K: in out Integer) is
begin
K := 3;
end Three;
end Foo;
--- test.adb
with Ada.Text_IO;
use Ada.Text_IO;
with Foo;
procedure Test is
package F is new Foo (M => 10);
begin
Put("hi");
end Test;
--
Summary: visibility problem with generic child package
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: koch at math dot utexas dot edu
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25988