From patchwork Mon Aug 29 08:22:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 111973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id ED508B6F77 for ; Mon, 29 Aug 2011 18:22:50 +1000 (EST) Received: (qmail 31428 invoked by alias); 29 Aug 2011 08:22:46 -0000 Received: (qmail 30930 invoked by uid 22791); 29 Aug 2011 08:22:42 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_20, RP_MATCHES_RCVD, TW_PR X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Aug 2011 08:22:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id CF010CB02B8; Mon, 29 Aug 2011 10:22:26 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OmFk7BUaxbtS; Mon, 29 Aug 2011 10:22:16 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 8D852CB02AC; Mon, 29 Aug 2011 10:22:16 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 60D0C24524F; Mon, 29 Aug 2011 10:22:20 +0200 (CEST) Date: Mon, 29 Aug 2011 10:22:20 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] New compiler attributes Dependency_Kind and Language_Kind Message-ID: <20110829082220.GA15242@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Two new configuration attributes for languages are added: Dependency_Kind and Language_Kind. No change of functionality so no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-29 Vincent Celier * prj-attr.adb: New Compiler attribute Dependency_Kind and Language_Kind * prj-conf.adb: Add_Default_GNAT_Naming_Scheme: Add a package Compiler with declarations for Language_Kind and Dependency_Kind for Ada. * prj-nmsc.adb (Check_Unit_Name): New name of procedure Check_Ada_Name (Process_Compiler): Take into account the new attributes Dependency_Kind and Language_Kind. (Check_Configuration): Check if language kind is unit based, not if the language name is Ada. (Process_Exceptions_Unit_Based): Ditto (Add_Language): Remove default additions of language and dependency kind * prj.ads: Minor comment change * snames.ads-tmpl: New standard names Dependency_Kind and Language_Kind Index: prj.ads =================================================================== --- prj.ads (revision 178155) +++ prj.ads (working copy) @@ -410,8 +410,8 @@ type Language_Config is record Kind : Language_Kind := File_Based; - -- Kind of language. All languages are file based, except Ada which is - -- unit based. + -- Kind of language. Most languages are file based. A few, such as Ada, + -- are unit based. Naming_Data : Lang_Naming_Data; -- The naming data for the languages (prefixes, etc.) Index: prj-nmsc.adb =================================================================== --- prj-nmsc.adb (revision 178155) +++ prj-nmsc.adb (working copy) @@ -281,8 +281,8 @@ -- Copy Str into Name_Buffer, replacing Pattern with Replacement. Str is -- converted to lower-case at the same time. - procedure Check_Ada_Name (Name : String; Unit : out Name_Id); - -- Check that a name is a valid Ada unit name + procedure Check_Unit_Name (Name : String; Unit : out Name_Id); + -- Check that a name is a valid unit name procedure Check_Package_Naming (Project : Project_Id; @@ -1112,11 +1112,11 @@ Debug_Decrease_Indent ("done check"); end Check; - -------------------- - -- Check_Ada_Name -- - -------------------- + --------------------- + -- Check_Unit_Name -- + --------------------- - procedure Check_Ada_Name (Name : String; Unit : out Name_Id) is + procedure Check_Unit_Name (Name : String; Unit : out Name_Id) is The_Name : String := Name; Real_Name : Name_Id; Need_Letter : Boolean := True; @@ -1164,7 +1164,7 @@ end if; end Is_Reserved; - -- Start of processing for Check_Ada_Name + -- Start of processing for Check_Unit_Name begin To_Lower (The_Name); @@ -1293,7 +1293,7 @@ Unit := No_Name; end if; - end Check_Ada_Name; + end Check_Unit_Name; ------------------------- -- Check_Configuration -- @@ -1492,6 +1492,26 @@ if Lang_Index /= No_Language_Index then case Current_Array.Name is + when Name_Dependency_Kind => + + -- Attribute Dependency_Kind () + + Get_Name_String (Element.Value.Value); + + begin + Lang_Index.Config.Dependency_Kind := + Dependency_File_Kind'Value + (Name_Buffer (1 .. Name_Len)); + + exception + when Constraint_Error => + Error_Msg + (Data.Flags, + "illegal value for Dependency_Kind", + Element.Value.Location, + Project); + end; + when Name_Dependency_Switches => -- Attribute Dependency_Switches () @@ -1526,6 +1546,25 @@ In_Tree => Data.Tree); end if; + when Name_Language_Kind => + -- Attribute Language_Kind () + + Get_Name_String (Element.Value.Value); + + begin + Lang_Index.Config.Kind := + Language_Kind'Value + (Name_Buffer (1 .. Name_Len)); + + exception + when Constraint_Error => + Error_Msg + (Data.Flags, + "illegal value for Language_Kind", + Element.Value.Location, + Project); + end; + when Name_Include_Switches => -- Attribute Include_Switches () @@ -1554,7 +1593,7 @@ -- Attribute Include_Path_File () Lang_Index.Config.Include_Path_File := - Element.Value.Value; + Element.Value.Value; when Name_Driver => @@ -1566,15 +1605,15 @@ when Name_Required_Switches | Name_Leading_Required_Switches => Put (Into_List => - Lang_Index.Config. - Compiler_Leading_Required_Switches, + Lang_Index.Config. + Compiler_Leading_Required_Switches, From_List => Element.Value.Values, In_Tree => Data.Tree); when Name_Trailing_Required_Switches => Put (Into_List => - Lang_Index.Config. - Compiler_Trailing_Required_Switches, + Lang_Index.Config. + Compiler_Trailing_Required_Switches, From_List => Element.Value.Values, In_Tree => Data.Tree); @@ -2575,7 +2614,7 @@ Lang_Index := Project.Languages; while Lang_Index /= No_Language_Index loop - if Lang_Index.Name = Name_Ada then + if Lang_Index.Config.Kind = Unit_Based then Lang_Index.Config.Naming_Data.Casing := Casing; Lang_Index.Config.Naming_Data.Dot_Replacement := Dot_Replacement; @@ -2627,7 +2666,7 @@ Prev_Index.Next := Lang_Index.Next; end if; - elsif Lang_Index.Name = Name_Ada then + elsif Lang_Index.Config.Kind = Unit_Based then Prev_Index := Lang_Index; -- For unit based languages, Dot_Replacement, Spec_Suffix and @@ -2636,21 +2675,24 @@ if Lang_Index.Config.Naming_Data.Dot_Replacement = No_File then Error_Msg (Data.Flags, - "Dot_Replacement not specified for Ada", + "Dot_Replacement not specified for " & + Get_Name_String (Lang_Index.Name), No_Location, Project); end if; if Lang_Index.Config.Naming_Data.Spec_Suffix = No_File then Error_Msg (Data.Flags, - "Spec_Suffix not specified for Ada", + "Spec_Suffix not specified for " & + Get_Name_String (Lang_Index.Name), No_Location, Project); end if; if Lang_Index.Config.Naming_Data.Body_Suffix = No_File then Error_Msg (Data.Flags, - "Body_Suffix not specified for Ada", + "Body_Suffix not specified for " & + Get_Name_String (Lang_Index.Name), No_Location, Project); end if; @@ -3189,7 +3231,6 @@ (Lang_Id : Language_Ptr; Kind : Source_Kind) is - Lang : constant Name_Id := Lang_Id.Name; Exceptions : Array_Element_Id; Element : Array_Element; Unit : Name_Id; @@ -3236,22 +3277,19 @@ Get_Name_String (Element.Index); To_Lower (Name_Buffer (1 .. Name_Len)); - Unit := Name_Find; Index := Element.Value.Index; - -- For Ada, check if it is a valid unit name + -- Check if it is a valid unit name - if Lang = Name_Ada then - Get_Name_String (Element.Index); - Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit); + Get_Name_String (Element.Index); + Check_Unit_Name (Name_Buffer (1 .. Name_Len), Unit); - if Unit = No_Name then - Err_Vars.Error_Msg_Name_1 := Element.Index; - Error_Msg - (Data.Flags, - "%% is not a valid unit name.", - Element.Value.Location, Project); - end if; + if Unit = No_Name then + Err_Vars.Error_Msg_Name_1 := Element.Index; + Error_Msg + (Data.Flags, + "%% is not a valid unit name.", + Element.Value.Location, Project); end if; if Unit /= No_Name then @@ -4344,13 +4382,6 @@ Project.Languages := Lang; Lang.Name := Name; Lang.Display_Name := Display_Name; - - if Name = Name_Ada then - Lang.Config.Kind := Unit_Based; - Lang.Config.Dependency_Kind := ALI_File; - else - Lang.Config.Kind := File_Based; - end if; end Add_Language; -- Start of processing for Check_Programming_Languages @@ -5690,7 +5721,7 @@ -- Name_Buffer contains the name of the unit in lower-cases. Check -- that this is a valid unit name - Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit); + Check_Unit_Name (Name_Buffer (1 .. Name_Len), Unit); -- If there is a naming exception for the same unit, the file is not -- a source for the unit. Index: prj-attr.adb =================================================================== --- prj-attr.adb (revision 178155) +++ prj-attr.adb (working copy) @@ -183,6 +183,8 @@ -- Configuration - Compiling "Sadriver#" & + "Salanguage_kind#" & + "Sadependency_kind#" & "Larequired_switches#" & "Laleading_required_switches#" & "Latrailing_required_switches#" & Index: prj-conf.adb =================================================================== --- prj-conf.adb (revision 178155) +++ prj-conf.adb (working copy) @@ -382,8 +382,9 @@ -- Local variables - Name : Name_Id; - Naming : Project_Node_Id; + Name : Name_Id; + Naming : Project_Node_Id; + Compiler : Project_Node_Id; -- Start of processing for Add_Default_GNAT_Naming_Scheme @@ -433,6 +434,12 @@ Create_Attribute (Name_Default_Language, "ada"); + Compiler := Create_Package (Project_Tree, Config_File, "compiler"); + Create_Attribute + (Name_Language_Kind, "unit_based", "ada", Pkg => Compiler); + Create_Attribute + (Name_Dependency_Kind, "ALI_File", "ada", Pkg => Compiler); + Naming := Create_Package (Project_Tree, Config_File, "naming"); Create_Attribute (Name_Spec_Suffix, ".ads", "ada", Pkg => Naming); Create_Attribute (Name_Separate_Suffix, ".adb", "ada", Pkg => Naming); Index: snames.ads-tmpl =================================================================== --- snames.ads-tmpl (revision 178155) +++ snames.ads-tmpl (working copy) @@ -1093,6 +1093,7 @@ Name_Default_Language : constant Name_Id := N + $; Name_Default_Switches : constant Name_Id := N + $; Name_Dependency_Driver : constant Name_Id := N + $; + Name_Dependency_Kind : constant Name_Id := N + $; Name_Dependency_Switches : constant Name_Id := N + $; Name_Driver : constant Name_Id := N + $; Name_Excluded_Source_Dirs : constant Name_Id := N + $; @@ -1121,6 +1122,7 @@ Name_Include_Path_File : constant Name_Id := N + $; Name_Inherit_Source_Path : constant Name_Id := N + $; Name_Languages : constant Name_Id := N + $; + Name_Language_Kind : constant Name_Id := N + $; Name_Leading_Library_Options : constant Name_Id := N + $; Name_Leading_Required_Switches : constant Name_Id := N + $; Name_Leading_Switches : constant Name_Id := N + $;