diff mbox

[Ada] gnatmake -gnatc does not always compile bodies

Message ID 20101005091635.GA17162@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 5, 2010, 9:16 a.m. UTC
When gnatmake has been invoked with -gnatc for a spec, if invoked later also
with -gnatct for the body, will not attempt compilation. This patch ensures
that the body is compiled.
The test for this is to invoke gnatmake -gnatc on a spec, then on the
corresponding body. In both cases the compiler should be invoked.

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

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

	* make.adb (Check): When compiling with -gnatc, recompile if the ALI
	file has not been generated for the current source, for example if it
	has been generated for the spec, but we are compiling the body.
diff mbox

Patch

Index: make.adb
===================================================================
--- make.adb	(revision 164942)
+++ make.adb	(working copy)
@@ -1658,6 +1658,32 @@  package body Make is
             return;
          end if;
 
+         --  When compiling with -gnatc, don't take ALI file into account if
+         --  it has not been generated for the current source, for example if
+         --  it has been generated for the spec, but we are compiling the body.
+
+         if Operating_Mode = Check_Semantics then
+            declare
+               File_Name : constant String := Get_Name_String (Source_File);
+               OK        : Boolean := False;
+
+            begin
+               for U in ALIs.Table (ALI).First_Unit ..
+                 ALIs.Table (ALI).Last_Unit
+               loop
+                  OK := Get_Name_String (Units.Table (U).Sfile) = File_Name;
+                  exit when OK;
+               end loop;
+
+               if not OK then
+                  Verbose_Msg
+                    (Full_Lib_File, "not generated for the same source");
+                  ALI := No_ALI_Id;
+                  return;
+               end if;
+            end;
+         end if;
+
          --  Check for matching compiler switches if needed
 
          if Check_Switches then