From 23ed6584d682ee5036850fdeb52cb7c22b8e3a0b Mon Sep 17 00:00:00 2001 From: Vincent Celier Date: Thu, 31 Jul 2008 12:27:30 +0200 Subject: [PATCH] prj-nmsc.adb (Check_Library_Attributes): Check if Linker'Switches or Linker'Default_Switches are declared. 2008-07-31 Vincent Celier * prj-nmsc.adb (Check_Library_Attributes): Check if Linker'Switches or Linker'Default_Switches are declared. Warn if they are declared. From-SVN: r138385 --- gcc/ada/prj-nmsc.adb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gcc/ada/prj-nmsc.adb b/gcc/ada/prj-nmsc.adb index f3b40b3a9e0..4e8384fc006 100644 --- a/gcc/ada/prj-nmsc.adb +++ b/gcc/ada/prj-nmsc.adb @@ -4104,6 +4104,46 @@ package body Prj.Nmsc is end if; end if; + -- Check if Linker'Switches or Linker'Default_Switches are declared. + -- Warn if they are declared, as it is a common error to think that + -- library are "linked" with Linker switches. + + if Data.Library then + declare + Linker_Package_Id : constant Package_Id := + Util.Value_Of (Name_Linker, Data.Decl.Packages, In_Tree); + Linker_Package : Package_Element; + Switches : Array_Element_Id := No_Array_Element; + + begin + if Linker_Package_Id /= No_Package then + Linker_Package := In_Tree.Packages.Table (Linker_Package_Id); + + Switches := + Value_Of + (Name => Name_Switches, + In_Arrays => Linker_Package.Decl.Arrays, + In_Tree => In_Tree); + + if Switches = No_Array_Element then + Switches := + Value_Of + (Name => Name_Default_Switches, + In_Arrays => Linker_Package.Decl.Arrays, + In_Tree => In_Tree); + end if; + + if Switches /= No_Array_Element then + Error_Msg + (Project, In_Tree, + "?Linker switches not taken into account in library " & + "projects", + No_Location); + end if; + end if; + end; + end if; + if Data.Extends /= No_Project then In_Tree.Projects.Table (Data.Extends).Library := False; end if; -- 2.30.2