Commit 0df218a9 by Arnaud Charlet

make.adb (Switches_Of): Check for Switches (others), before checking for Default_Switches ("Ada").

2008-08-05  Vincent Celier  <celier@adacore.com>

	* make.adb (Switches_Of): Check for Switches (others), before checking
	for Default_Switches ("Ada").
	(Gnatmake): Use Builder'Switches (others) in preference to
	Builder'Default_Switches ("Ada") if there are several mains.

	* prj-attr-pm.adb:
	(Add_Attribute): Add component Others_Allowed in Attribute_Record
	aggregate.

	* prj-attr.adb:
	Add markers to indicates that attributes Switches allow others as index
	(Others_Allowed_For): New Boolean function, returning True for
	attributes with the mark.
	(Initialize): Recognize optional letter 'O' as the marker for
	associative array attributes where others is allowed as the index.

	* prj-attr.ads:
	(Others_Allowed_For): New Boolean function
	(Attribute_Record): New Boolean component Others_Allowed
	
	* prj-dect.adb:
	(Parse_Attribute_Declaration): For associative array attribute where
	others is allowed as the index, allow others as an index.

	* prj-nmsc.adb:
	(Process_Binder): Skip associative array attributes with index others
	(Process_Compiler): Ditto

	* prj-util.adb:
	(Value_Of (Index, In_Array)): Make no attempt to put in lower case when
	index is All_Other_Names.

	* prj.ads:
	(All_Other_Names): New constant

From-SVN: r138683
parent 9cc014f9
2008-08-05 Vincent Celier <celier@adacore.com>
* mlib.adb: Update comments.
* make.adb (Switches_Of): Check for Switches (others), before checking
for Default_Switches ("Ada").
(Gnatmake): Use Builder'Switches (others) in preference to
Builder'Default_Switches ("Ada") if there are several mains.
* prj-attr-pm.adb:
(Add_Attribute): Add component Others_Allowed in Attribute_Record
aggregate.
* prj-attr.adb:
Add markers to indicates that attributes Switches allow others as index
(Others_Allowed_For): New Boolean function, returning True for
attributes with the mark.
(Initialize): Recognize optional letter 'O' as the marker for
associative array attributes where others is allowed as the index.
* prj-attr.ads:
(Others_Allowed_For): New Boolean function
(Attribute_Record): New Boolean component Others_Allowed
* prj-dect.adb:
(Parse_Attribute_Declaration): For associative array attribute where
others is allowed as the index, allow others as an index.
* prj-nmsc.adb:
(Process_Binder): Skip associative array attributes with index others
(Process_Compiler): Ditto
* prj-util.adb:
(Value_Of (Index, In_Array)): Make no attempt to put in lower case when
index is All_Other_Names.
* prj.ads:
(All_Other_Names): New constant
* prj-proc.adb:
(Process_Declarative_Items): Skip associative array attribute when index
is reserved word "others".
2008-08-05 Vasiliy Fofanov <fofanov@adacore.com>
* gen-oscons.c: Adapt for VMS where termios.h is not available.
2008-08-05 Thomas Quinot <quinot@adacore.com> 2008-08-05 Thomas Quinot <quinot@adacore.com>
* a-rttiev.adb: Minor reformatting (comments) * a-rttiev.adb: Minor reformatting (comments)
...@@ -645,8 +645,9 @@ package body Make is ...@@ -645,8 +645,9 @@ package body Make is
-- project file. If the Source_File ends with a standard GNAT extension -- project file. If the Source_File ends with a standard GNAT extension
-- (".ads" or ".adb"), try first the full name, then the name without the -- (".ads" or ".adb"), try first the full name, then the name without the
-- extension, then, if Allow_ALI is True, the name with the extension -- extension, then, if Allow_ALI is True, the name with the extension
-- ".ali". If there is no switches for either names, try the default -- ".ali". If there is no switches for either names, try first Switches
-- switches for Ada. If all failed, return No_Variable_Value. -- (others) then the default switches for Ada. If all failed, return
-- No_Variable_Value.
function Is_In_Object_Directory function Is_In_Object_Directory
(Source_File : File_Name_Type; (Source_File : File_Name_Type;
...@@ -3463,6 +3464,7 @@ package body Make is ...@@ -3463,6 +3464,7 @@ package body Make is
-- If an ALI file was generated by this compilation, scan -- If an ALI file was generated by this compilation, scan
-- the ALI file and record it. -- the ALI file and record it.
-- If the scan fails, a previous ali file is inconsistent with -- If the scan fails, a previous ali file is inconsistent with
-- the unit just compiled. -- the unit just compiled.
...@@ -5123,9 +5125,34 @@ package body Make is ...@@ -5123,9 +5125,34 @@ package body Make is
(Builder_Package).Decl.Arrays, (Builder_Package).Decl.Arrays,
In_Tree => Project_Tree); In_Tree => Project_Tree);
Other_Switches : constant Variable_Value :=
Prj.Util.Value_Of
(Name => All_Other_Names,
Index => 0,
Attribute_Or_Array_Name => Name_Switches,
In_Package => Builder_Package,
In_Tree => Project_Tree);
begin begin
if Defaults /= Nil_Variable_Value then if Other_Switches /= Nil_Variable_Value then
if (not Quiet_Output) if not Quiet_Output
and then Switches /= No_Array_Element
and then Project_Tree.Array_Elements.Table
(Switches).Next /= No_Array_Element
then
Write_Line
("Warning: using Builder'Switches(others), " &
"as there are several mains");
end if;
Add_Switches
(File_Name => " ",
Index => 0,
The_Package => Builder_Package,
Program => None);
elsif Defaults /= Nil_Variable_Value then
if not Quiet_Output
and then Switches /= No_Array_Element and then Switches /= No_Array_Element
then then
Write_Line Write_Line
...@@ -5133,21 +5160,18 @@ package body Make is ...@@ -5133,21 +5160,18 @@ package body Make is
"(""Ada""), as there are several mains"); "(""Ada""), as there are several mains");
end if; end if;
-- As there is never a source with name " ", we are
-- guaranteed to always get the general switches.
Add_Switches Add_Switches
(File_Name => " ", (File_Name => " ",
Index => 0, Index => 0,
The_Package => Builder_Package, The_Package => Builder_Package,
Program => None); Program => None);
elsif (not Quiet_Output) elsif not Quiet_Output
and then Switches /= No_Array_Element and then Switches /= No_Array_Element
then then
Write_Line Write_Line
("Warning: using no switches from package Builder," & ("Warning: using no switches from package " &
" as there are several mains"); "Builder, as there are several mains");
end if; end if;
end; end;
end if; end if;
...@@ -8165,6 +8189,15 @@ package body Make is ...@@ -8165,6 +8189,15 @@ package body Make is
if Switches = Nil_Variable_Value then if Switches = Nil_Variable_Value then
Switches := Switches :=
Prj.Util.Value_Of Prj.Util.Value_Of
(Index => All_Other_Names,
Src_Index => 0,
In_Array => Switches_Array,
In_Tree => Project_Tree);
end if;
if Switches = Nil_Variable_Value then
Switches :=
Prj.Util.Value_Of
(Index => Name_Ada, (Index => Name_Ada,
Src_Index => 0, Src_Index => 0,
In_Array => Defaults, In_Array => Defaults,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2007, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -45,6 +45,7 @@ package body Prj.Attr.PM is ...@@ -45,6 +45,7 @@ package body Prj.Attr.PM is
Optional_Index => False, Optional_Index => False,
Attr_Kind => Unknown, Attr_Kind => Unknown,
Read_Only => False, Read_Only => False,
Others_Allowed => False,
Next => Next =>
Package_Attributes.Table (To_Package.Value).First_Attribute); Package_Attributes.Table (To_Package.Value).First_Attribute);
Package_Attributes.Table (To_Package.Value).First_Attribute := Package_Attributes.Table (To_Package.Value).First_Attribute :=
......
...@@ -56,6 +56,8 @@ package body Prj.Attr is ...@@ -56,6 +56,8 @@ package body Prj.Attr is
-- The third optional letter is -- The third optional letter is
-- 'R' to indicate that the attribute is read-only -- 'R' to indicate that the attribute is read-only
-- 'O' to indicate that others is allowed as an index for an associative
-- array
-- End is indicated by two consecutive '#' -- End is indicated by two consecutive '#'
...@@ -159,7 +161,7 @@ package body Prj.Attr is ...@@ -159,7 +161,7 @@ package body Prj.Attr is
"Pcompiler#" & "Pcompiler#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lcswitches#" & "LcOswitches#" &
"SVlocal_configuration_pragmas#" & "SVlocal_configuration_pragmas#" &
"Salocal_config_file#" & "Salocal_config_file#" &
...@@ -200,7 +202,7 @@ package body Prj.Attr is ...@@ -200,7 +202,7 @@ package body Prj.Attr is
"Pbuilder#" & "Pbuilder#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lcswitches#" & "LcOswitches#" &
"Lcglobal_compilation_switches#" & "Lcglobal_compilation_switches#" &
"Scexecutable#" & "Scexecutable#" &
"SVexecutable_suffix#" & "SVexecutable_suffix#" &
...@@ -216,7 +218,7 @@ package body Prj.Attr is ...@@ -216,7 +218,7 @@ package body Prj.Attr is
"Pbinder#" & "Pbinder#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lcswitches#" & "LcOswitches#" &
-- Configuration - Binding -- Configuration - Binding
...@@ -231,7 +233,7 @@ package body Prj.Attr is ...@@ -231,7 +233,7 @@ package body Prj.Attr is
"Plinker#" & "Plinker#" &
"LVrequired_switches#" & "LVrequired_switches#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lcswitches#" & "LcOswitches#" &
"LVlinker_options#" & "LVlinker_options#" &
"SVmap_file_option#" & "SVmap_file_option#" &
...@@ -246,49 +248,49 @@ package body Prj.Attr is ...@@ -246,49 +248,49 @@ package body Prj.Attr is
"Pcross_reference#" & "Pcross_reference#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Finder -- package Finder
"Pfinder#" & "Pfinder#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Pretty_Printer -- package Pretty_Printer
"Ppretty_printer#" & "Ppretty_printer#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package gnatstub -- package gnatstub
"Pgnatstub#" & "Pgnatstub#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Check -- package Check
"Pcheck#" & "Pcheck#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Synchronize -- package Synchronize
"Psynchronize#" & "Psynchronize#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Eliminate -- package Eliminate
"Peliminate#" & "Peliminate#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Metrics -- package Metrics
"Pmetrics#" & "Pmetrics#" &
"Ladefault_switches#" & "Ladefault_switches#" &
"Lbswitches#" & "LbOswitches#" &
-- package Ide -- package Ide
...@@ -411,6 +413,7 @@ package body Prj.Attr is ...@@ -411,6 +413,7 @@ package body Prj.Attr is
Attribute_Name : Name_Id := No_Name; Attribute_Name : Name_Id := No_Name;
First_Attribute : Attr_Node_Id := Attr.First_Attribute; First_Attribute : Attr_Node_Id := Attr.First_Attribute;
Read_Only : Boolean; Read_Only : Boolean;
Others_Allowed : Boolean;
function Attribute_Location return String; function Attribute_Location return String;
-- Returns a string depending if we are in the project level attributes -- Returns a string depending if we are in the project level attributes
...@@ -538,12 +541,16 @@ package body Prj.Attr is ...@@ -538,12 +541,16 @@ package body Prj.Attr is
Start := Start + 1; Start := Start + 1;
Read_Only := False;
Others_Allowed := False;
if Initialization_Data (Start) = 'R' then if Initialization_Data (Start) = 'R' then
Read_Only := True; Read_Only := True;
Start := Start + 1; Start := Start + 1;
else elsif Initialization_Data (Start) = 'O' then
Read_Only := False; Others_Allowed := True;
Start := Start + 1;
end if; end if;
Finish := Start; Finish := Start;
...@@ -586,6 +593,7 @@ package body Prj.Attr is ...@@ -586,6 +593,7 @@ package body Prj.Attr is
Optional_Index => Optional_Index, Optional_Index => Optional_Index,
Attr_Kind => Attr_Kind, Attr_Kind => Attr_Kind,
Read_Only => Read_Only, Read_Only => Read_Only,
Others_Allowed => Others_Allowed,
Next => Empty_Attr); Next => Empty_Attr);
Start := Finish + 1; Start := Finish + 1;
end if; end if;
...@@ -643,6 +651,17 @@ package body Prj.Attr is ...@@ -643,6 +651,17 @@ package body Prj.Attr is
end if; end if;
end Optional_Index_Of; end Optional_Index_Of;
function Others_Allowed_For
(Attribute : Attribute_Node_Id) return Boolean
is
begin
if Attribute = Empty_Attribute then
return False;
else
return Attrs.Table (Attribute.Value).Others_Allowed;
end if;
end Others_Allowed_For;
----------------------- -----------------------
-- Package_Name_List -- -- Package_Name_List --
----------------------- -----------------------
...@@ -750,6 +769,7 @@ package body Prj.Attr is ...@@ -750,6 +769,7 @@ package body Prj.Attr is
Optional_Index => Opt_Index, Optional_Index => Opt_Index,
Attr_Kind => Real_Attr_Kind, Attr_Kind => Real_Attr_Kind,
Read_Only => False, Read_Only => False,
Others_Allowed => False,
Next => First_Attr); Next => First_Attr);
Package_Attributes.Table (In_Package.Value).First_Attribute := Package_Attributes.Table (In_Package.Value).First_Attribute :=
...@@ -856,6 +876,7 @@ package body Prj.Attr is ...@@ -856,6 +876,7 @@ package body Prj.Attr is
Optional_Index => Attributes (Index).Opt_Index, Optional_Index => Attributes (Index).Opt_Index,
Attr_Kind => Attr_Kind, Attr_Kind => Attr_Kind,
Read_Only => False, Read_Only => False,
Others_Allowed => False,
Next => First_Attr); Next => First_Attr);
First_Attr := Attrs.Last; First_Attr := Attrs.Last;
end loop; end loop;
......
...@@ -169,6 +169,10 @@ package Prj.Attr is ...@@ -169,6 +169,10 @@ package Prj.Attr is
-- Returns Empty_Attribute if After is either Empty_Attribute or is the -- Returns Empty_Attribute if After is either Empty_Attribute or is the
-- last of the list. -- last of the list.
function Others_Allowed_For (Attribute : Attribute_Node_Id) return Boolean;
-- Returns True if the index for an associative array attributes may be
-- others.
-------------- --------------
-- Packages -- -- Packages --
-------------- --------------
...@@ -282,6 +286,7 @@ private ...@@ -282,6 +286,7 @@ private
Optional_Index : Boolean; Optional_Index : Boolean;
Attr_Kind : Attribute_Kind; Attr_Kind : Attribute_Kind;
Read_Only : Boolean; Read_Only : Boolean;
Others_Allowed : Boolean;
Next : Attr_Node_Id; Next : Attr_Node_Id;
end record; end record;
-- Data for an attribute -- Data for an attribute
......
...@@ -223,8 +223,9 @@ package body Prj.Dect is ...@@ -223,8 +223,9 @@ package body Prj.Dect is
else else
if Is_Read_Only (Current_Attribute) then if Is_Read_Only (Current_Attribute) then
Error_Msg_Name_1 := Token_Name;
Error_Msg Error_Msg
("read-only attribute cannot be given a value", ("read-only attribute %% cannot be given a value",
Token_Ptr); Token_Ptr);
end if; end if;
...@@ -284,7 +285,20 @@ package body Prj.Dect is ...@@ -284,7 +285,20 @@ package body Prj.Dect is
end if; end if;
Scan (In_Tree); -- past the left parenthesis Scan (In_Tree); -- past the left parenthesis
if Others_Allowed_For (Current_Attribute)
and then Token = Tok_Others
then
Set_Associative_Array_Index_Of
(Attribute, In_Tree, All_Other_Names);
Scan (In_Tree); -- past others
else
if Others_Allowed_For (Current_Attribute) then
Expect (Tok_String_Literal, "literal string or others");
else
Expect (Tok_String_Literal, "literal string"); Expect (Tok_String_Literal, "literal string");
end if;
if Token = Tok_String_Literal then if Token = Tok_String_Literal then
Get_Name_String (Token_Name); Get_Name_String (Token_Name);
...@@ -332,6 +346,7 @@ package body Prj.Dect is ...@@ -332,6 +346,7 @@ package body Prj.Dect is
end case; end case;
end if; end if;
end if; end if;
end if;
Expect (Tok_Right_Paren, "`)`"); Expect (Tok_Right_Paren, "`)`");
......
...@@ -1295,6 +1295,7 @@ package body Prj.Nmsc is ...@@ -1295,6 +1295,7 @@ package body Prj.Nmsc is
while Element_Id /= No_Array_Element loop while Element_Id /= No_Array_Element loop
Element := In_Tree.Array_Elements.Table (Element_Id); Element := In_Tree.Array_Elements.Table (Element_Id);
if Element.Index /= All_Other_Names then
-- Get the name of the language -- Get the name of the language
Get_Language_Index_Of (Element.Index); Get_Language_Index_Of (Element.Index);
...@@ -1344,6 +1345,7 @@ package body Prj.Nmsc is ...@@ -1344,6 +1345,7 @@ package body Prj.Nmsc is
null; null;
end case; end case;
end if; end if;
end if;
Element_Id := Element.Next; Element_Id := Element.Next;
end loop; end loop;
...@@ -1405,6 +1407,7 @@ package body Prj.Nmsc is ...@@ -1405,6 +1407,7 @@ package body Prj.Nmsc is
while Element_Id /= No_Array_Element loop while Element_Id /= No_Array_Element loop
Element := In_Tree.Array_Elements.Table (Element_Id); Element := In_Tree.Array_Elements.Table (Element_Id);
if Element.Index /= All_Other_Names then
-- Get the name of the language -- Get the name of the language
Get_Language_Index_Of (Element.Index); Get_Language_Index_Of (Element.Index);
...@@ -1673,6 +1676,7 @@ package body Prj.Nmsc is ...@@ -1673,6 +1676,7 @@ package body Prj.Nmsc is
null; null;
end case; end case;
end if; end if;
end if;
Element_Id := Element.Next; Element_Id := Element.Next;
end loop; end loop;
......
...@@ -600,20 +600,24 @@ package body Prj.Util is ...@@ -600,20 +600,24 @@ package body Prj.Util is
Real_Index_1 := Index; Real_Index_1 := Index;
if not Element.Index_Case_Sensitive or Force_Lower_Case_Index then if not Element.Index_Case_Sensitive or Force_Lower_Case_Index then
if Index /= All_Other_Names then
Get_Name_String (Index); Get_Name_String (Index);
To_Lower (Name_Buffer (1 .. Name_Len)); To_Lower (Name_Buffer (1 .. Name_Len));
Real_Index_1 := Name_Find; Real_Index_1 := Name_Find;
end if; end if;
end if;
while Current /= No_Array_Element loop while Current /= No_Array_Element loop
Element := In_Tree.Array_Elements.Table (Current); Element := In_Tree.Array_Elements.Table (Current);
Real_Index_2 := Element.Index; Real_Index_2 := Element.Index;
if not Element.Index_Case_Sensitive or Force_Lower_Case_Index then if not Element.Index_Case_Sensitive or Force_Lower_Case_Index then
if Element.Index /= All_Other_Names then
Get_Name_String (Element.Index); Get_Name_String (Element.Index);
To_Lower (Name_Buffer (1 .. Name_Len)); To_Lower (Name_Buffer (1 .. Name_Len));
Real_Index_2 := Name_Find; Real_Index_2 := Name_Find;
end if; end if;
end if;
if Real_Index_1 = Real_Index_2 and then if Real_Index_1 = Real_Index_2 and then
Src_Index = Element.Src_Index Src_Index = Element.Src_Index
......
...@@ -40,6 +40,10 @@ with GNAT.OS_Lib; use GNAT.OS_Lib; ...@@ -40,6 +40,10 @@ with GNAT.OS_Lib; use GNAT.OS_Lib;
package Prj is package Prj is
All_Other_Names : constant Name_Id := Names_High_Bound;
-- Name used to replace others as an index of an associative array
-- attribute, when allowed.
Subdirs_Option : constant String := "--subdirs="; Subdirs_Option : constant String := "--subdirs=";
-- Switch used to indicate that the real directories (object, exec, -- Switch used to indicate that the real directories (object, exec,
-- library, ...) are subdirectories of what is indicated in the project -- library, ...) are subdirectories of what is indicated in the project
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment