#244970 Illegal program not detected, RM 12.1(11)

Package:
gnat-12
Source:
gcc-12
Description:
GNU Ada compiler
Submitter:
Date:
2024-05-09 17:36:21 UTC
Severity:
normal
Tags:
#244970#5
Date:
2004-04-20 21:33:07 UTC
From:
To:
generic
package pak1 is
end pak1;

generic
package pak1.pak2 is
end pak1.pak2;

with pak1.pak2;
generic
   with package new_pak2 is new pak1.pak2;  -- ERROR: illegal use of pak1
package pak5 is
end pak5;



$ gnatchop -w p; gnatmake -gnatVa pak5
splitting p into:
   pak1.ads
   pak1-pak2.ads
   pak5.ads
gnatgcc -c -gnatVa pak5.ads
gnatgcc -c -gnatVa pak1.ads
gnatgcc -c -gnatVa pak1-pak2.ads

Compilation finished at Tue Apr 20 18:46:10

The error in the above program is kind of subtle, but relates to RM
12.1(11) (note 1): "Outside a generic unit a name that denotes the
generic_declaration denotes the generic unit."

Since pak5 is outside the generic unit pak1, pak1 refers
to the generic pak1, which must be instantiated before it
can be used to refer to child units such as pak1.pak2.

In this similar example:

   generic
   package pak1 is
   end pak1;

   generic
   package pak1.pak2 is
   end pak1.pak2;

   with pak1.pak2;
   generic
--    with package new_pak2 is new pak1.pak2;
   package pak5 is
      package new_pak2 is new pak1.pak2;  --ERROR:
   end pak5;


gnat correctly reports the error:
   invalid prefix in selected component "pak1"


A legal version of the original example (which gnat correctly accepts)
would be:

   generic
   package pak1 is
   end pak1;

   generic
   package pak1.pak2 is
   end pak1.pak2;

   with pak1.pak2;
   generic
      with package new_pak1 is new pak1;
      with package new_pak2 is new new_pak1.pak2;  --OK new_pak1 not pak1
   package pak5 is
   end pak5;

#244970#20
Date:
2008-12-29 23:15:57 UTC
From:
To:
found 244970 4.3.2-2
thanks

#244970#31
Date:
2009-08-02 18:20:26 UTC
From:
To:
found 244970 in 4.4.1-1
thanks