diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:01:59 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:01:59 +0200 |
commit | 0df5ae93e08e17fbe36bfcd1bda8ea24af968a64 (patch) | |
tree | 160aed62a8b7dc8baaecb1c3e3d236c979273971 /gcc/ada/makeutl.adb | |
parent | 9db78a423bbd92dfbfcaa5b33b040da21540d647 (diff) | |
download | gcc-0df5ae93e08e17fbe36bfcd1bda8ea24af968a64.tar.gz |
[multiple changes]
2014-05-21 Robert Dewar <dewar@adacore.com>
* 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 <schonberg@adacore.com>
* 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 <celier@adacore.com>
* 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
Diffstat (limited to 'gcc/ada/makeutl.adb')
-rw-r--r-- | gcc/ada/makeutl.adb | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/gcc/ada/makeutl.adb b/gcc/ada/makeutl.adb index a220cbec0e2..d9772510cac 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 |