From patchwork Thu Jun 17 12:27:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56032 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 713841007D2 for ; Thu, 17 Jun 2010 22:27:21 +1000 (EST) Received: (qmail 7105 invoked by alias); 17 Jun 2010 12:27:15 -0000 Received: (qmail 6855 invoked by uid 22791); 17 Jun 2010 12:27:12 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_PR, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jun 2010 12:27:03 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D7958CB02A9; Thu, 17 Jun 2010 14:27:08 +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 BC0pL1clM96j; Thu, 17 Jun 2010 14:27:08 +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 C572FCB02A7; Thu, 17 Jun 2010 14:27:08 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id CDD12D9AB0; Thu, 17 Jun 2010 14:27:18 +0200 (CEST) Date: Thu, 17 Jun 2010 14:27:18 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] Extending project does not inherit Linker_Options Message-ID: <20100617122718.GA9227@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 An extending project no longer inherit attribute Linker'Linker_Options, to avoid repeating the same options several times, which may ead to linking error. The test for this is to build an executable with a project A that declares Linker'Linker_Options and a project B extending A that don't declare package Linker and is not the main project. The linker options in A should not be repeated when the linker is invoked. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Vincent Celier * prj-proc.adb (Copy_Package_Declarations): Change argument name Naming_Restricted to Restricted. If Restricted is True, do not copy the value of attribute Linker_Options. Index: prj-proc.adb =================================================================== --- prj-proc.adb (revision 160875) +++ prj-proc.adb (working copy) @@ -87,15 +87,15 @@ package body Prj.Proc is -- based languages) procedure Copy_Package_Declarations - (From : Declarations; - To : in out Declarations; - New_Loc : Source_Ptr; - Naming_Restricted : Boolean; - In_Tree : Project_Tree_Ref); + (From : Declarations; + To : in out Declarations; + New_Loc : Source_Ptr; + Restricted : Boolean; + In_Tree : Project_Tree_Ref); -- Copy a package declaration From to To for a renamed package. Change the - -- locations of all the attributes to New_Loc. When Naming_Restricted is - -- True, do not copy attributes Body, Spec, Implementation and - -- Specification. + -- locations of all the attributes to New_Loc. When Restricted is + -- True, do not copy attributes Body, Spec, Implementation, Specification + -- and Linker_Options. function Expression (Project : Project_Id; @@ -314,11 +314,11 @@ package body Prj.Proc is ------------------------------- procedure Copy_Package_Declarations - (From : Declarations; - To : in out Declarations; - New_Loc : Source_Ptr; - Naming_Restricted : Boolean; - In_Tree : Project_Tree_Ref) + (From : Declarations; + To : in out Declarations; + New_Loc : Source_Ptr; + Restricted : Boolean; + In_Tree : Project_Tree_Ref) is V1 : Variable_Id; V2 : Variable_Id := No_Variable; @@ -346,6 +346,12 @@ package body Prj.Proc is Var := In_Tree.Variable_Elements.Table (V1); V1 := Var.Next; + -- Do not copy the value of attribute inker_Options if Restricted + + if Restricted and then Var.Name = Snames.Name_Linker_Options then + Var.Value.Values := Nil_String; + end if; + -- Remove the Next component Var.Next := No_Variable; @@ -376,16 +382,16 @@ package body Prj.Proc is Arr := In_Tree.Arrays.Table (A1); A1 := Arr.Next; - if not Naming_Restricted or else - (Arr.Name /= Snames.Name_Body - and then Arr.Name /= Snames.Name_Spec - and then Arr.Name /= Snames.Name_Implementation - and then Arr.Name /= Snames.Name_Specification) + if not Restricted + or else + (Arr.Name /= Snames.Name_Body and then + Arr.Name /= Snames.Name_Spec and then + Arr.Name /= Snames.Name_Implementation and then + Arr.Name /= Snames.Name_Specification) then -- Remove the Next component Arr.Next := No_Array; - Array_Table.Increment_Last (In_Tree.Arrays); -- Create new Array declaration @@ -1445,15 +1451,15 @@ package body Prj.Proc is -- renaming declaration. Copy_Package_Declarations - (From => + (From => In_Tree.Packages.Table (Renamed_Package).Decl, - To => + To => In_Tree.Packages.Table (New_Pkg).Decl, - New_Loc => + New_Loc => Location_Of (Current_Item, From_Project_Node_Tree), - Naming_Restricted => False, - In_Tree => In_Tree); + Restricted => False, + In_Tree => In_Tree); end; -- Standard package declaration, not renaming @@ -2621,13 +2627,12 @@ package body Prj.Proc is Next => Project.Decl.Packages); Project.Decl.Packages := Current_Pkg; Copy_Package_Declarations - (From => Element.Decl, - To => + (From => Element.Decl, + To => In_Tree.Packages.Table (Current_Pkg).Decl, - New_Loc => No_Location, - Naming_Restricted => - Element.Name = Snames.Name_Naming, - In_Tree => In_Tree); + New_Loc => No_Location, + Restricted => True, + In_Tree => In_Tree); end if; Extended_Pkg := Element.Next;