This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/15603] New: Illegal program not detected, 12.7(10) (generic parameter is visible, shouldn't be)


GNAT compiles the following illegal program.

generic
package P1 is
end P1;

with P1;
generic
   with package the_P1 is new P1; -- [1]
package P2 is
end P2;

with P1;
package new_P1 is new P1;

with new_P1, P2;
package P3 is
   package new_P2 is new P2(new_P1);
   package my_P1 renames new_P2.the_P1;   -- ERROR: the_P1 is not visible
end P3;

$ gnatchop -w p; gnatmake p3
splitting p into:
   p1.ads
   p2.ads
   new_p1.ads
   p3.ads
gcc -c p3.ads
gcc -c new_p1.ads
gcc -c p2.ads
gcc -c p1.ads

Compilation finished at Wed Apr 14 19:11:19

12.7(10):
"The visible part of a formal package includes the first list of
basic_declarative_items of the package_specification. In addition, if
the formal_package_actual_part is (<>), it also includes the
generic_formal_part of the template for the formal package."

Here, the formal_package_actual_part at line [1] is not (<>),
therefore the_P1 is not part of P2's visible part.  Here is an example
where gnat correctly applies this rule:

generic
   i: integer;
package P2 is
end P2;

with P2;
package P3 is
   package new_P2 is new P2(3);
   x: integer renames new_P2.i;
end P3;

$ gnatchop -w p; gnatmake p3
splitting p into:
   p2.ads
   p3.ads
gcc -c p3.ads
p3.ads:5:29: "i" is not a visible entity of "new_P2"
gnatmake: "p3.ads" compilation error

-- 
           Summary: Illegal program not detected, 12.7(10) (generic
                    parameter is visible, shouldn't be)
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ludovic dot brenta at insalien dot org
                CC: gcc-bugs at gcc dot gnu dot org
 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=15603


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]