[Bug ada/15602] New: Illegal program not detected, 7.2(4)

ludovic dot brenta at insalien dot org gcc-bugzilla@gcc.gnu.org
Sun May 23 23:33:00 GMT 2004


The following program compiles, binds, links and prints "hello world"
when run.  It shouldn't link because the body for pak5 isn't allowed
unless the spec for pak5 has a (correctly spelled) pragma
elaborate_body, since there is nothing else in the spec of pak5 that
would require a body.

RM 7.2(4):

"A library package_declaration or library generic_package_declaration
shall not have a body unless it requires a body; pragma Elaborate_body
can be used to require a library_unit declaration to have a body (see
10.2.1) if it would not otherwise require one."

Here is the program:

package pak1 is
end pak1;

generic
package pak1.pak2 is
   pragma elaborate_body;
end pak1.pak2;

package body pak1.pak2 is
end pak1.pak2;


with pak1.pak2;
generic
   with package new_pak2 is new pak1.pak2(<>);
package pak5 is
   pragma eaoaeoy;         -- ERROR: can't abbreviate elaborate_body
end pak5;

with text_io;
package body pak5 is
begin
   text_io.put_line("hello world");
end pak5;

with pak5;
with pak1.pak2;
procedure test20 is
   package new_pak2 is new pak1.pak2;
   package new_pak5 is new pak5(new_pak2);
begin
   null;
end;


The trace below shows that GNAT compiles pak5.adb when it shouldn't.

$ gnatchop -w p; gnatmake test20
splitting p into:
   pak1.ads
   pak1-pak2.ads
   pak1-pak2.adb
   pak5.ads
   pak5.adb
   test20.adb
gcc -c test20.adb
pak5.ads:7:04: warning: unrecognized pragma "eaoaeoy"
gcc -c pak1.ads
gcc -c pak1-pak2.adb
gcc -c pak5.adb
pak5.ads:7:04: warning: unrecognized pragma "eaoaeoy"
gnatbind -x test20.ali
gnatlink test20.ali
$ ./test20
hello world

-- 
           Summary: Illegal program not detected, 7.2(4)
           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=15602



More information about the Gcc-bugs mailing list