Patchwork [Ada] No ALI generated when compiler fails on a spec that needs a body

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 12, 2010, 1:10 p.m.
Message ID <20101012131036.GA28303@adacore.com>
Download mbox | patch
Permalink /patch/67552/
State New
Headers show

Comments

Arnaud Charlet - Oct. 12, 2010, 1:10 p.m.
An ALI is no longer generated when the compiler is invoked on a spec that
needs a body, when neither -gnatc nor -gnatQ is used.
The test for this is to invoke "gcc -c pkg.ads" with a package Pkg that
needs a body. No pkg.ali should be created.

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

2010-10-12  Vincent Celier  <celier@adacore.com>

	* gnat1drv.adb: When the compiler is invoked for a spec that needs aw
	body, do not generate an ALI file if neither -gnatc nor -gnatQ is used.

Patch

Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb	(revision 165366)
+++ gnat1drv.adb	(working copy)
@@ -863,10 +863,18 @@  begin
             Write_Str (" (missing subunits)");
             Write_Eol;
 
+            --  Force generation of ALI file, for backward compatibility
+
+            Opt.Force_ALI_Tree_File := True;
+
          elsif Main_Kind = N_Subunit then
             Write_Str (" (subunit)");
             Write_Eol;
 
+            --  Force generation of ALI file, for backward compatibility
+
+            Opt.Force_ALI_Tree_File := True;
+
          elsif Main_Kind = N_Subprogram_Declaration then
             Write_Str (" (subprogram spec)");
             Write_Eol;
@@ -877,6 +885,10 @@  begin
             Write_Str (" (predefined generic)");
             Write_Eol;
 
+            --  Force generation of ALI file, for backward compatibility
+
+            Opt.Force_ALI_Tree_File := True;
+
          --  Only other case is a package spec
 
          else
@@ -893,7 +905,14 @@  begin
          Errout.Output_Messages;
          Treepr.Tree_Dump;
          Tree_Gen;
-         Write_ALI (Object => False);
+
+         --  Generate ALI file if specially requested, or for missing subunits,
+         --  subunits or predefined generic.
+
+         if Opt.Force_ALI_Tree_File then
+            Write_ALI (Object => False);
+         end if;
+
          Namet.Finalize;
          Check_Rep_Info;