From 0df5ae93e08e17fbe36bfcd1bda8ea24af968a64 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 21 May 2014 15:01:59 +0200 Subject: [multiple changes] 2014-05-21 Robert Dewar * sem_ch13.adb (Analyze_Aspect_Specifications): Insert_Delayed_Pragma is now used for the case of Attach_Handler. * sem_prag.adb: Minor comment improvements. 2014-05-21 Ed Schonberg * sem_ch12.adb (Install_Body): When checking whether freezing of instantiation must be delayed, verify that the common enclosing subprogram to generic and instance is in fact an overloadable entity. 2014-05-21 Vincent Celier * makeutl.adb (Mains.Complete_Mains.Do_Complete): Look for all mains with the same name and fail if there is more than one. * prj.ads, prj.adb (Find_All_Sources): New function From-SVN: r210702 --- gcc/ada/makeutl.adb | 59 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'gcc/ada/makeutl.adb') diff --git a/gcc/ada/makeutl.adb b/gcc/ada/makeutl.adb index a220cbe..d977251 100644 --- a/gcc/ada/makeutl.adb +++ b/gcc/ada/makeutl.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1732,7 +1732,7 @@ package body Makeutl is -- no need to process them in turn. J := Names.Last; - loop + Main_Loop : loop declare File : Main_Info := Names.Table (J); Main_Id : File_Name_Type := File.File; @@ -1798,16 +1798,53 @@ package body Makeutl is -- search for the base name though, and if needed -- check later that we found the correct file. - Source := Find_Source - (In_Tree => File.Tree, - Project => File.Project, - Base_Name => Main_Id, - Index => File.Index, - In_Imported_Only => True); + declare + Sources : constant Source_Ids := + Find_All_Sources + (In_Tree => File.Tree, + Project => File.Project, + Base_Name => Main_Id, + Index => File.Index, + In_Imported_Only => True); + + begin + if Is_Absolute then + for J in Sources'Range loop + if File_Name_Type (Sources (J).Path.Name) = + File.File + then + Source := Sources (J); + exit; + end if; + end loop; + + elsif Sources'Length > 1 then + + -- This is only allowed if the units are from + -- the same multi-unit source file. + + Source := Sources (1); + + for J in 2 .. Sources'Last loop + if Sources (J).Path /= Source.Path + or else Sources (J).Index = Source.Index + then + Error_Msg_File_1 := Main_Id; + Prj.Err.Error_Msg + (Flags, "several main sources {", + No_Location, File.Project); + exit Main_Loop; + end if; + end loop; + + elsif Sources'Length = 1 then + Source := Sources (Sources'First); + end if; + end; if Source = No_Source then Source := Find_File_Add_Extension - (File.Tree, Get_Name_String (Main_Id)); + (File.Tree, Get_Name_String (Main_Id)); end if; if Is_Absolute @@ -1883,8 +1920,8 @@ package body Makeutl is end; J := J - 1; - exit when J < Names.First; - end loop; + exit Main_Loop when J < Names.First; + end loop Main_Loop; end if; if Total_Errors_Detected > 0 then -- cgit v1.1