[Ada] add attribute Excluded_Source_Files

Arnaud Charlet charlet@adacore.com
Fri Sep 7 13:06:00 GMT 2007


Tested on i686-linux, committed on trunk

Attribute Locally_Removed_Files has been restricted to extending projects
only, then has been allowed in all projects. So its name is not really
adapted. A new attribute Excluded_Source_Files is created. If this new
attribute is not declared, for compatibility, Locally_Removed_Files is
used, if declared.

The following project should build correctly, with the appended files in
the same directory:

prj.gpr:
project Prj is
   for Main use ("main.adb");
   for Excluded_Source_Files use ("pkg.adb");
end Prj;

main.adb:
procedure Main is
begin
   null;
end;

pkg.ads:
package Pkg is
end;

pkg.adb:
package body Pkg is
end;

2007-08-31  Vincent Celier  <celier@adacore.com>

	* prj-attr.adb: Add new attribute Excluded_Source_Files

	* prj-nmsc.adb: Use attribute Excluded_Source_Files before
	Locally_Removed_Files.

	* snames.ads, snames.adb: New standard name Excluded_Source_Files

-------------- next part --------------
Index: prj-attr.adb
===================================================================
--- prj-attr.adb	(revision 127923)
+++ prj-attr.adb	(working copy)
@@ -75,12 +75,13 @@ package body Prj.Attr is
    "SVobject_dir#" &
    "SVexec_dir#" &
    "LVsource_dirs#" &
-   "LVremoved_source_dirs#" &
+   "LVexcluded_source_dirs#" &
 
    --  Source files
 
    "LVsource_files#" &
    "LVlocally_removed_files#" &
+   "LVexcluded_source_files#" &
    "SVsource_list_file#" &
 
    --  Libraries
Index: prj-nmsc.adb
===================================================================
--- prj-nmsc.adb	(revision 127923)
+++ prj-nmsc.adb	(working copy)
@@ -4812,9 +4812,9 @@ package body Prj.Nmsc is
                       Util.Value_Of
                         (Name_Source_Dirs, Data.Decl.Attributes, In_Tree);
 
-      Removed_Source_Dirs : constant Variable_Value :=
+      Excluded_Source_Dirs : constant Variable_Value :=
                               Util.Value_Of
-                                (Name_Removed_Source_Dirs,
+                                (Name_Excluded_Source_Dirs,
                                  Data.Decl.Attributes,
                                  In_Tree);
 
@@ -5416,12 +5416,13 @@ package body Prj.Nmsc is
 
       else
          declare
-            Source_Dir : String_List_Id := Source_Dirs.Values;
+            Source_Dir : String_List_Id;
             Element    : String_Element;
 
          begin
             --  Process the source directories for each element of the list
 
+            Source_Dir := Source_Dirs.Values;
             while Source_Dir /= Nil_String loop
                Element :=
                  In_Tree.String_Elements.Table (Source_Dir);
@@ -5432,8 +5433,9 @@ package body Prj.Nmsc is
          end;
       end if;
 
-      if (not Removed_Source_Dirs.Default) and then
-        Removed_Source_Dirs.Values /= Nil_String then
+      if not Excluded_Source_Dirs.Default
+        and then Excluded_Source_Dirs.Values /= Nil_String
+      then
          declare
             Source_Dir : String_List_Id;
             Element    : String_Element;
@@ -5441,7 +5443,7 @@ package body Prj.Nmsc is
          begin
             --  Process the source directories for each element of the list
 
-            Source_Dir := Removed_Source_Dirs.Values;
+            Source_Dir := Excluded_Source_Dirs.Values;
             while Source_Dir /= Nil_String loop
                Element :=
                  In_Tree.String_Elements.Table (Source_Dir);
@@ -6883,9 +6885,9 @@ package body Prj.Nmsc is
                                     Data.Decl.Attributes,
                                     In_Tree);
 
-            Locally_Removed  : constant Variable_Value :=
+            Excluded_Sources : Variable_Value :=
                                  Util.Value_Of
-                                   (Name_Locally_Removed_Files,
+                                   (Name_Excluded_Source_Files,
                                     Data.Decl.Attributes,
                                     In_Tree);
 
@@ -7008,13 +7010,24 @@ package body Prj.Nmsc is
                  (Project, In_Tree, Data, Follow_Links);
             end if;
 
+            --  If Excluded_ource_Files is not declared, check
+            --  Locally_Removed_Files.
+
+            if Excluded_Sources.Default then
+               Excluded_Sources :=
+                 Util.Value_Of
+                   (Name_Locally_Removed_Files,
+                    Data.Decl.Attributes,
+                    In_Tree);
+            end if;
+
             --  If there are sources that are locally removed, mark them as
             --  such in the Units table.
 
-            if not Locally_Removed.Default then
+            if not Excluded_Sources.Default then
 
                declare
-                  Current  : String_List_Id := Locally_Removed.Values;
+                  Current  : String_List_Id := Excluded_Sources.Values;
                   Element  : String_Element;
                   Location : Source_Ptr;
                   OK       : Boolean;
@@ -7030,10 +7043,10 @@ package body Prj.Nmsc is
                      Name := Name_Find;
 
                      --  If the element has no location, then use the location
-                     --  of Locally_Removed to report possible errors.
+                     --  of Excluded_Sources to report possible errors.
 
                      if Element.Location = No_Location then
-                        Location := Locally_Removed.Location;
+                        Location := Excluded_Sources.Location;
                      else
                         Location := Element.Location;
                      end if;
@@ -7409,14 +7422,25 @@ package body Prj.Nmsc is
                                     Data.Decl.Attributes,
                                     In_Tree);
 
-            Locally_Removed  : constant Variable_Value :=
+            Excluded_Sources : Variable_Value :=
                                  Util.Value_Of
-                                   (Name_Locally_Removed_Files,
+                                   (Name_Excluded_Source_Files,
                                     Data.Decl.Attributes,
                                     In_Tree);
             Name_Loc         : Name_Location;
 
          begin
+            --  If Excluded_ource_Files is not declared, check
+            --  Locally_Removed_Files.
+
+            if Excluded_Sources.Default then
+               Excluded_Sources :=
+                 Util.Value_Of
+                   (Name_Locally_Removed_Files,
+                    Data.Decl.Attributes,
+                    In_Tree);
+            end if;
+
             if not Sources.Default then
                if not Source_List_File.Default then
                   Error_Msg
@@ -7517,7 +7541,7 @@ package body Prj.Nmsc is
 
             --  If there are locally removed sources, mark them as such
 
-            if not Locally_Removed.Default then
+            if not Excluded_Sources.Default then
                declare
                   Current  : String_List_Id;
                   Element  : String_Element;
@@ -7528,7 +7552,7 @@ package body Prj.Nmsc is
                   Src_Data : Source_Data;
 
                begin
-                  Current := Locally_Removed.Values;
+                  Current := Excluded_Sources.Values;
                   while Current /= Nil_String loop
                      Element :=
                        In_Tree.String_Elements.Table (Current);
@@ -7537,10 +7561,10 @@ package body Prj.Nmsc is
                      Name := Name_Find;
 
                      --  If the element has no location, then use the location
-                     --  of Locally_Removed to report possible errors.
+                     --  of Excluded_Sources to report possible errors.
 
                      if Element.Location = No_Location then
-                        Location := Locally_Removed.Location;
+                        Location := Excluded_Sources.Location;
                      else
                         Location := Element.Location;
                      end if;
Index: snames.ads
===================================================================
--- snames.ads	(revision 127923)
+++ snames.ads	(working copy)
@@ -1011,104 +1011,105 @@ package Snames is
    Name_Dependency_File_Kind           : constant Name_Id := N + 634;
    Name_Dependency_Switches            : constant Name_Id := N + 635;
    Name_Driver                         : constant Name_Id := N + 636;
-   Name_Exec_Dir                       : constant Name_Id := N + 637;
-   Name_Executable                     : constant Name_Id := N + 638;
-   Name_Executable_Suffix              : constant Name_Id := N + 639;
-   Name_Extends                        : constant Name_Id := N + 640;
-   Name_Externally_Built               : constant Name_Id := N + 641;
-   Name_Finder                         : constant Name_Id := N + 642;
-   Name_Global_Configuration_Pragmas   : constant Name_Id := N + 643;
-   Name_Global_Config_File             : constant Name_Id := N + 644;
-   Name_Gnatls                         : constant Name_Id := N + 645;
-   Name_Gnatstub                       : constant Name_Id := N + 646;
-   Name_Implementation                 : constant Name_Id := N + 647;
-   Name_Implementation_Exceptions      : constant Name_Id := N + 648;
-   Name_Implementation_Suffix          : constant Name_Id := N + 649;
-   Name_Include_Option                 : constant Name_Id := N + 650;
-   Name_Include_Path                   : constant Name_Id := N + 651;
-   Name_Include_Path_File              : constant Name_Id := N + 652;
-   Name_Language_Kind                  : constant Name_Id := N + 653;
-   Name_Language_Processing            : constant Name_Id := N + 654;
-   Name_Languages                      : constant Name_Id := N + 655;
-   Name_Library_Ali_Dir                : constant Name_Id := N + 656;
-   Name_Library_Auto_Init              : constant Name_Id := N + 657;
-   Name_Library_Auto_Init_Supported    : constant Name_Id := N + 658;
-   Name_Library_Builder                : constant Name_Id := N + 659;
-   Name_Library_Dir                    : constant Name_Id := N + 660;
-   Name_Library_GCC                    : constant Name_Id := N + 661;
-   Name_Library_Interface              : constant Name_Id := N + 662;
-   Name_Library_Kind                   : constant Name_Id := N + 663;
-   Name_Library_Name                   : constant Name_Id := N + 664;
-   Name_Library_Major_Minor_Id_Supported : constant Name_Id := N + 665;
-   Name_Library_Options                : constant Name_Id := N + 666;
-   Name_Library_Partial_Linker         : constant Name_Id := N + 667;
-   Name_Library_Reference_Symbol_File  : constant Name_Id := N + 668;
-   Name_Library_Src_Dir                : constant Name_Id := N + 669;
-   Name_Library_Support                : constant Name_Id := N + 670;
-   Name_Library_Symbol_File            : constant Name_Id := N + 671;
-   Name_Library_Symbol_Policy          : constant Name_Id := N + 672;
-   Name_Library_Version                : constant Name_Id := N + 673;
-   Name_Library_Version_Switches       : constant Name_Id := N + 674;
-   Name_Linker                         : constant Name_Id := N + 675;
-   Name_Linker_Executable_Option       : constant Name_Id := N + 676;
-   Name_Linker_Lib_Dir_Option          : constant Name_Id := N + 677;
-   Name_Linker_Lib_Name_Option         : constant Name_Id := N + 678;
-   Name_Local_Config_File              : constant Name_Id := N + 679;
-   Name_Local_Configuration_Pragmas    : constant Name_Id := N + 680;
-   Name_Locally_Removed_Files          : constant Name_Id := N + 681;
-   Name_Mapping_File_Switches          : constant Name_Id := N + 682;
-   Name_Mapping_Spec_Suffix            : constant Name_Id := N + 683;
-   Name_Mapping_Body_Suffix            : constant Name_Id := N + 684;
-   Name_Metrics                        : constant Name_Id := N + 685;
-   Name_Naming                         : constant Name_Id := N + 686;
-   Name_Objects_Path                   : constant Name_Id := N + 687;
-   Name_Objects_Path_File              : constant Name_Id := N + 688;
-   Name_Object_Dir                     : constant Name_Id := N + 689;
-   Name_Pic_Option                     : constant Name_Id := N + 690;
-   Name_Pretty_Printer                 : constant Name_Id := N + 691;
-   Name_Prefix                         : constant Name_Id := N + 692;
-   Name_Project                        : constant Name_Id := N + 693;
-   Name_Roots                          : constant Name_Id := N + 694;
-   Name_Removed_Source_Dirs            : constant Name_Id := N + 695;
-   Name_Required_Switches              : constant Name_Id := N + 696;
-   Name_Run_Path_Option                : constant Name_Id := N + 697;
-   Name_Runtime_Project                : constant Name_Id := N + 698;
-   Name_Shared_Library_Minimum_Switches : constant Name_Id := N + 699;
-   Name_Shared_Library_Prefix          : constant Name_Id := N + 700;
-   Name_Shared_Library_Suffix          : constant Name_Id := N + 701;
-   Name_Separate_Suffix                : constant Name_Id := N + 702;
-   Name_Source_Dirs                    : constant Name_Id := N + 703;
-   Name_Source_Files                   : constant Name_Id := N + 704;
-   Name_Source_List_File               : constant Name_Id := N + 705;
-   Name_Spec                           : constant Name_Id := N + 706;
-   Name_Spec_Suffix                    : constant Name_Id := N + 707;
-   Name_Specification                  : constant Name_Id := N + 708;
-   Name_Specification_Exceptions       : constant Name_Id := N + 709;
-   Name_Specification_Suffix           : constant Name_Id := N + 710;
-   Name_Stack                          : constant Name_Id := N + 711;
-   Name_Switches                       : constant Name_Id := N + 712;
-   Name_Symbolic_Link_Supported        : constant Name_Id := N + 713;
-   Name_Toolchain_Description          : constant Name_Id := N + 714;
-   Name_Toolchain_Version              : constant Name_Id := N + 715;
+   Name_Excluded_Source_Dirs           : constant Name_Id := N + 637;
+   Name_Excluded_Source_Files          : constant Name_Id := N + 638;
+   Name_Exec_Dir                       : constant Name_Id := N + 639;
+   Name_Executable                     : constant Name_Id := N + 640;
+   Name_Executable_Suffix              : constant Name_Id := N + 641;
+   Name_Extends                        : constant Name_Id := N + 642;
+   Name_Externally_Built               : constant Name_Id := N + 643;
+   Name_Finder                         : constant Name_Id := N + 644;
+   Name_Global_Configuration_Pragmas   : constant Name_Id := N + 645;
+   Name_Global_Config_File             : constant Name_Id := N + 646;
+   Name_Gnatls                         : constant Name_Id := N + 647;
+   Name_Gnatstub                       : constant Name_Id := N + 648;
+   Name_Implementation                 : constant Name_Id := N + 649;
+   Name_Implementation_Exceptions      : constant Name_Id := N + 650;
+   Name_Implementation_Suffix          : constant Name_Id := N + 651;
+   Name_Include_Option                 : constant Name_Id := N + 652;
+   Name_Include_Path                   : constant Name_Id := N + 653;
+   Name_Include_Path_File              : constant Name_Id := N + 654;
+   Name_Language_Kind                  : constant Name_Id := N + 655;
+   Name_Language_Processing            : constant Name_Id := N + 656;
+   Name_Languages                      : constant Name_Id := N + 657;
+   Name_Library_Ali_Dir                : constant Name_Id := N + 658;
+   Name_Library_Auto_Init              : constant Name_Id := N + 659;
+   Name_Library_Auto_Init_Supported    : constant Name_Id := N + 660;
+   Name_Library_Builder                : constant Name_Id := N + 661;
+   Name_Library_Dir                    : constant Name_Id := N + 662;
+   Name_Library_GCC                    : constant Name_Id := N + 663;
+   Name_Library_Interface              : constant Name_Id := N + 664;
+   Name_Library_Kind                   : constant Name_Id := N + 665;
+   Name_Library_Name                   : constant Name_Id := N + 666;
+   Name_Library_Major_Minor_Id_Supported : constant Name_Id := N + 667;
+   Name_Library_Options                : constant Name_Id := N + 668;
+   Name_Library_Partial_Linker         : constant Name_Id := N + 669;
+   Name_Library_Reference_Symbol_File  : constant Name_Id := N + 670;
+   Name_Library_Src_Dir                : constant Name_Id := N + 671;
+   Name_Library_Support                : constant Name_Id := N + 672;
+   Name_Library_Symbol_File            : constant Name_Id := N + 673;
+   Name_Library_Symbol_Policy          : constant Name_Id := N + 674;
+   Name_Library_Version                : constant Name_Id := N + 675;
+   Name_Library_Version_Switches       : constant Name_Id := N + 676;
+   Name_Linker                         : constant Name_Id := N + 677;
+   Name_Linker_Executable_Option       : constant Name_Id := N + 678;
+   Name_Linker_Lib_Dir_Option          : constant Name_Id := N + 679;
+   Name_Linker_Lib_Name_Option         : constant Name_Id := N + 680;
+   Name_Local_Config_File              : constant Name_Id := N + 681;
+   Name_Local_Configuration_Pragmas    : constant Name_Id := N + 682;
+   Name_Locally_Removed_Files          : constant Name_Id := N + 683;
+   Name_Mapping_File_Switches          : constant Name_Id := N + 684;
+   Name_Mapping_Spec_Suffix            : constant Name_Id := N + 685;
+   Name_Mapping_Body_Suffix            : constant Name_Id := N + 686;
+   Name_Metrics                        : constant Name_Id := N + 687;
+   Name_Naming                         : constant Name_Id := N + 688;
+   Name_Objects_Path                   : constant Name_Id := N + 689;
+   Name_Objects_Path_File              : constant Name_Id := N + 690;
+   Name_Object_Dir                     : constant Name_Id := N + 691;
+   Name_Pic_Option                     : constant Name_Id := N + 692;
+   Name_Pretty_Printer                 : constant Name_Id := N + 693;
+   Name_Prefix                         : constant Name_Id := N + 694;
+   Name_Project                        : constant Name_Id := N + 695;
+   Name_Roots                          : constant Name_Id := N + 696;
+   Name_Required_Switches              : constant Name_Id := N + 697;
+   Name_Run_Path_Option                : constant Name_Id := N + 698;
+   Name_Runtime_Project                : constant Name_Id := N + 699;
+   Name_Shared_Library_Minimum_Switches : constant Name_Id := N + 700;
+   Name_Shared_Library_Prefix          : constant Name_Id := N + 701;
+   Name_Shared_Library_Suffix          : constant Name_Id := N + 702;
+   Name_Separate_Suffix                : constant Name_Id := N + 703;
+   Name_Source_Dirs                    : constant Name_Id := N + 704;
+   Name_Source_Files                   : constant Name_Id := N + 705;
+   Name_Source_List_File               : constant Name_Id := N + 706;
+   Name_Spec                           : constant Name_Id := N + 707;
+   Name_Spec_Suffix                    : constant Name_Id := N + 708;
+   Name_Specification                  : constant Name_Id := N + 709;
+   Name_Specification_Exceptions       : constant Name_Id := N + 710;
+   Name_Specification_Suffix           : constant Name_Id := N + 711;
+   Name_Stack                          : constant Name_Id := N + 712;
+   Name_Switches                       : constant Name_Id := N + 713;
+   Name_Symbolic_Link_Supported        : constant Name_Id := N + 714;
+   Name_Toolchain_Description          : constant Name_Id := N + 715;
+   Name_Toolchain_Version              : constant Name_Id := N + 716;
 
    --  Other miscellaneous names used in front end
 
-   Name_Unaligned_Valid                : constant Name_Id := N + 716;
+   Name_Unaligned_Valid                : constant Name_Id := N + 717;
 
    --  Ada 2005 reserved words
 
-   First_2005_Reserved_Word            : constant Name_Id := N + 717;
-   Name_Interface                      : constant Name_Id := N + 717;
-   Name_Overriding                     : constant Name_Id := N + 718;
-   Name_Synchronized                   : constant Name_Id := N + 719;
-   Last_2005_Reserved_Word             : constant Name_Id := N + 719;
+   First_2005_Reserved_Word            : constant Name_Id := N + 718;
+   Name_Interface                      : constant Name_Id := N + 718;
+   Name_Overriding                     : constant Name_Id := N + 719;
+   Name_Synchronized                   : constant Name_Id := N + 720;
+   Last_2005_Reserved_Word             : constant Name_Id := N + 720;
 
    subtype Ada_2005_Reserved_Words is
      Name_Id range First_2005_Reserved_Word .. Last_2005_Reserved_Word;
 
    --  Mark last defined name for consistency check in Snames body
 
-   Last_Predefined_Name                : constant Name_Id := N + 719;
+   Last_Predefined_Name                : constant Name_Id := N + 720;
 
    ---------------------------------------
    -- Subtypes Defining Name Categories --
Index: snames.adb
===================================================================
--- snames.adb	(revision 127923)
+++ snames.adb	(working copy)
@@ -695,6 +695,8 @@ package body Snames is
      "dependency_file_kind#" &
      "dependency_switches#" &
      "driver#" &
+     "excluded_source_dirs#" &
+     "excluded_source_files#" &
      "exec_dir#" &
      "executable#" &
      "executable_suffix#" &
@@ -753,7 +755,6 @@ package body Snames is
      "prefix#" &
      "project#" &
      "roots#" &
-     "removed_source_dirs#" &
      "required_switches#" &
      "run_path_option#" &
      "runtime_project#" &


More information about the Gcc-patches mailing list