diff mbox series

[Ada] Do not generate .ali files for subunits

Message ID 20170908091322.GA88791@adacore.com
State New
Headers show
Series [Ada] Do not generate .ali files for subunits | expand

Commit Message

Arnaud Charlet Sept. 8, 2017, 9:13 a.m. UTC
This patch fixes a bug in which the compiler creates .ali files when a
subunit is compiled. Given the following code:

package P is
  procedure F;
end P;

package body P is
  procedure F is separate;
end P;

separate (P)
procedure F is
begin
  null;
end F;

The command:

gcc -c p-f.adb

should generate an error:

cannot generate code for file p-f.adb (subunit)

and p-f.ali should not be created.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-08  Bob Duff  <duff@adacore.com>

	* gnat1drv.adb (Gnat1drv): Do not set the Force_ALI_Tree_File flag in
	the subunit case. It's still OK to set it in the "missing subunits"
	case, because that won't cause the obsolete .ali files that cause
	confusion.
diff mbox series

Patch

Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb	(revision 251863)
+++ gnat1drv.adb	(working copy)
@@ -1353,10 +1353,10 @@ 
                Write_Str (" (subunit)");
                Write_Eol;
 
-               --  Force generation of ALI file, for backward compatibility
+               --  Do not generate an ALI file in this case, because it would
+               --  become obsolete when the parent is compiled, and thus
+               --  confuse tools such as gnatfind.
 
-               Opt.Force_ALI_Tree_File := True;
-
             elsif Main_Unit_Kind = N_Subprogram_Declaration then
                Write_Str (" (subprogram spec)");
                Write_Eol;