http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48039

           Summary: Legal program rejected, a formal function is not
                    visible in generic
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: demoon...@panathenaia.halfmoon.jp


Created attachment 23589
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23589
minimal bug triggering source code

Name lookup is abnormal in complex generic code with gcc-4.5.1/4.5.2.

-- p.ads
package p is
end p;

-- p-gh.ads
generic
function p.gh return Integer;

-- p-gh.adb
function p.gh return Integer is
begin
   return 0;
end p.gh;

-- p-gu.ads
generic
package p.gu is
   generic
      with function h return Integer is <>;
      -- with function fh return Integer is <>; -- ok
   function gh return Integer;
end p.gu;

-- p-gu.adb
package body p.gu is
   function gh return Integer is
   begin
      return h; -- error !!
      -- return fh; -- ok
   end gh;
end p.gu;

-- p-h.ads
with p.gh;
function p.h is new gh;

-- p-u.ads
with p.gu;
package p.u is new gu;

-- p-r.ads
with p.u;
package p.r is
end p.r;

-- p-r-h.ads
with p.h;
function p.r.h is new u.gh (h);

% gnatmake p-r-h.ads 
gcc -c p-r-h.ads
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: "h" is not visible
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: non-visible declaration at line 4
p-r-h.ads:4:01: instantiation error at p-gu.adb:6
p-r-h.ads:4:01: non-visible declaration at p-h.ads:4
gnatmake: "p-r-h.ads" compilation error

This code will be compiled If we rename formal function h to another name (for
example, fh).

Reply via email to