From patchwork Mon Oct 29 10:08:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 194934 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 93CA92C0086 for ; Mon, 29 Oct 2012 21:12:34 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352110354; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=hZUo6DagHCEsET4KJfSu MFql7yA=; b=HRxNaICfk7b3eatva73JVuP8JIMBh9vYzJl72++M/TKP3Vo+QwnL 5FFrqJ2IPokGfegAQl+SJMgQ+HHZh+YHj3iRLPHtPp1OSfJsmtinxsvYF6H7ZqBe tSjW04BZkP/e1rUI4Hbuyg6Czpfeg4PkI24RzUCd9fvm1irxRSjgcn0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yI59d6hy5Cpe3dIcrK9ukLr1p9XcRMj1F1ym3L4vEjOH9IfY6HHUfZQCOg+4vL 9UKYSp9EW3RqtEynM13f7rBG13sbVw5aWX1a0dInjJ7oj8YzMJM+4IxqEeKCBPl4 mzYiA0O1LZnQPqXTDBgEu7jd6nlTWXk26IMsJPg3z0wdI=; Received: (qmail 3365 invoked by alias); 29 Oct 2012 10:12:27 -0000 Received: (qmail 31908 invoked by uid 22791); 29 Oct 2012 10:08:52 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Oct 2012 10:08:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 054621C7BE8; Mon, 29 Oct 2012 06:08:25 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ElIHorKH1jVu; Mon, 29 Oct 2012 06:08:24 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id E0FD21C790B; Mon, 29 Oct 2012 06:08:24 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id E0ACE3FF09; Mon, 29 Oct 2012 06:08:24 -0400 (EDT) Date: Mon, 29 Oct 2012 06:08:24 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Source location of generated nodes for To_Any calls Message-ID: <20121029100824.GA21030@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This change modifies the source location assigned to expander generated nodes produced in the context of the distributed systems annex. Previously, we always assigned code generated for the conversion of an expression to the intermediate Any representation the location of the expression. However when such a call is generated as part of the generation of calling stubs for an RACW, this may lead to spurious ABE warnings if the RACW is declared earlier than the point where the expression occurs (case e.g. of a default value of a discriminant for a discriminated type used as formal parameter type in an RACW primitive operation, when the discriminated type declaration occurs after the RACW declaration). Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-29 Thomas Quinot * exp_attr.adb, exp_dist.adb, exp_dist.ads (Build_To_Any_Call): Pass an explicit Loc parameter to set the source location of generated nodes. Index: exp_attr.adb =================================================================== --- exp_attr.adb (revision 192908) +++ exp_attr.adb (working copy) @@ -5141,7 +5141,8 @@ begin Rewrite (N, Build_To_Any_Call - (Convert_To (P_Type, + (Loc, + Convert_To (P_Type, Relocate_Node (First (Exprs))), Decls)); Insert_Actions (N, Decls); Analyze_And_Resolve (N, RTE (RE_Any)); Index: exp_dist.adb =================================================================== --- exp_dist.adb (revision 192908) +++ exp_dist.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- 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- -- @@ -803,12 +803,14 @@ -- the declaration and entity for the newly-created function. function Build_To_Any_Call - (N : Node_Id; + (Loc : Source_Ptr; + N : Node_Id; Decls : List_Id) return Node_Id; -- Build call to To_Any attribute function with expression as actual - -- parameter. Decls is the declarations list for an appropriate - -- enclosing scope of the point where the call will be inserted; if - -- the To_Any attribute for Typ needs to be generated at this point, + -- parameter. Loc is the reference location ofr generated nodes, + -- Decls is the declarations list for an appropriate enclosing scope + -- of the point where the call will be inserted; if the To_Any + -- attribute for the type of N needs to be generated at this point, -- its declaration is appended to Decls. procedure Build_To_Any_Function @@ -879,7 +881,8 @@ renames PolyORB_Support.Helpers.Build_From_Any_Call; function Build_To_Any_Call - (N : Node_Id; + (Loc : Source_Ptr; + N : Node_Id; Decls : List_Id) return Node_Id renames PolyORB_Support.Helpers.Build_To_Any_Call; @@ -6562,7 +6565,7 @@ Object_Definition => New_Occurrence_Of (RTE (RE_Any), Loc), Expression => PolyORB_Support.Helpers.Build_To_Any_Call - (RACW_Parameter, No_List))); + (Loc, RACW_Parameter, No_List))); Statements := New_List ( Make_Procedure_Call_Statement (Loc, @@ -7362,7 +7365,7 @@ -- the first one. Expr := PolyORB_Support.Helpers.Build_To_Any_Call - (Actual_Parameter, Decls); + (Loc, Actual_Parameter, Decls); else Expr := Make_Function_Call (Loc, @@ -7448,7 +7451,7 @@ New_Occurrence_Of (RTE (RE_Any), Loc), Expression => PolyORB_Support.Helpers.Build_To_Any_Call - (Parameter_Exp, Decls))); + (Loc, Parameter_Exp, Decls))); Append_To (Extra_Formal_Statements, Add_Parameter_To_NVList (Loc, @@ -7934,7 +7937,7 @@ Parameter_Associations => New_List ( New_Occurrence_Of (Any, Loc), PolyORB_Support.Helpers.Build_To_Any_Call - (New_Occurrence_Of (Object, Loc), Decls)))); + (Loc, New_Occurrence_Of (Object, Loc), Decls)))); end if; -- For RACW controlling formals, the Etyp of Object is always @@ -8094,7 +8097,7 @@ Parameter_Associations => New_List ( New_Occurrence_Of (Request_Parameter, Loc), PolyORB_Support.Helpers.Build_To_Any_Call - (New_Occurrence_Of (Result, Loc), Decls)))); + (Loc, New_Occurrence_Of (Result, Loc), Decls)))); -- A DSA function does not have out or inout arguments end; @@ -9219,11 +9222,10 @@ ----------------------- function Build_To_Any_Call - (N : Node_Id; + (Loc : Source_Ptr; + N : Node_Id; Decls : List_Id) return Node_Id is - Loc : constant Source_Ptr := Sloc (N); - Typ : Entity_Id := Etype (N); U_Type : Entity_Id; C_Type : Entity_Id; @@ -9463,7 +9465,8 @@ (Rt_Type, New_Occurrence_Of (Expr_Parameter, Loc)); begin - Set_Expression (Any_Decl, Build_To_Any_Call (Expr, Decls)); + Set_Expression (Any_Decl, + Build_To_Any_Call (Loc, Expr, Decls)); end; elsif Is_Record_Type (Typ) and then not Is_Tagged_Type (Typ) then @@ -9479,7 +9482,7 @@ begin Set_Expression - (Any_Decl, Build_To_Any_Call (Expr, Decls)); + (Any_Decl, Build_To_Any_Call (Loc, Expr, Decls)); end; -- Comment needed here (and label on declare block ???) @@ -9535,7 +9538,7 @@ RTE (RE_Add_Aggregate_Element), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Container, Loc), - Build_To_Any_Call (Field_Ref, Decls)))); + Build_To_Any_Call (Loc, Field_Ref, Decls)))); else -- A variant part @@ -9660,7 +9663,8 @@ Parameter_Associations => New_List ( New_Occurrence_Of (Union_Any, Loc), Build_To_Any_Call - (Make_Discriminant_Reference, + (Loc, + Make_Discriminant_Reference, Block_Decls)))); -- Populate inner struct aggregate @@ -9761,7 +9765,8 @@ Choices => New_List ( Make_Integer_Literal (Loc, Counter)), Expression => - Build_To_Any_Call (Discriminant, Decls))); + Build_To_Any_Call (Loc, + Discriminant, Decls))); end; Counter := Counter + 1; @@ -9850,7 +9855,7 @@ if Etype (Datum) = RTE (RE_Any) then Element_Any := Datum; else - Element_Any := Build_To_Any_Call (Datum, Decls); + Element_Any := Build_To_Any_Call (Loc, Datum, Decls); end if; Append_To (Stmts, @@ -9889,7 +9894,7 @@ RTE (RE_Add_Aggregate_Element), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Any, Loc), - Build_To_Any_Call ( + Build_To_Any_Call (Loc, OK_Convert_To (Etype (Index), Make_Attribute_Reference (Loc, Prefix => @@ -9910,7 +9915,7 @@ -- Integer types Set_Expression (Any_Decl, - Build_To_Any_Call ( + Build_To_Any_Call (Loc, OK_Convert_To ( Find_Numeric_Representation (Typ), New_Occurrence_Of (Expr_Parameter, Loc)), @@ -10454,7 +10459,7 @@ Set_Etype (Expr, Disc_Type); Append_To (Union_TC_Params, - Build_To_Any_Call (Expr, Decls)); + Build_To_Any_Call (Loc, Expr, Decls)); Add_Params_For_Variant_Components; J := J + Uint_1; @@ -10495,7 +10500,7 @@ begin Set_Etype (Exp, Disc_Type); Append_To (Union_TC_Params, - Build_To_Any_Call (Exp, Decls)); + Build_To_Any_Call (Loc, Exp, Decls)); end; Add_Params_For_Variant_Components; @@ -10509,7 +10514,7 @@ New_Copy_Tree (Choice); begin Append_To (Union_TC_Params, - Build_To_Any_Call (Exp, Decls)); + Build_To_Any_Call (Loc, Exp, Decls)); end; Add_Params_For_Variant_Components; @@ -10679,7 +10684,7 @@ if Constrained then Inner_TypeCode := Make_Constructed_TypeCode (RTE (RE_TC_Array), New_List ( - Build_To_Any_Call ( + Build_To_Any_Call (Loc, OK_Convert_To (RTE (RE_Unsigned_32), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Typ, Loc), @@ -10688,7 +10693,7 @@ Make_Integer_Literal (Loc, Intval => Ndim - J + 1)))), Decls), - Build_To_Any_Call (Inner_TypeCode, Decls))); + Build_To_Any_Call (Loc, Inner_TypeCode, Decls))); else -- Unconstrained case: add low bound for each @@ -10705,11 +10710,11 @@ Inner_TypeCode := Make_Constructed_TypeCode (RTE (RE_TC_Sequence), New_List ( - Build_To_Any_Call ( + Build_To_Any_Call (Loc, OK_Convert_To (RTE (RE_Unsigned_32), Make_Integer_Literal (Loc, 0)), Decls), - Build_To_Any_Call (Inner_TypeCode, Decls))); + Build_To_Any_Call (Loc, Inner_TypeCode, Decls))); end if; end loop; Index: exp_dist.ads =================================================================== --- exp_dist.ads (revision 192908) +++ exp_dist.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- 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- -- @@ -144,13 +144,14 @@ -- declaration is appended to Decls. function Build_To_Any_Call - (N : Node_Id; + (Loc : Source_Ptr; + N : Node_Id; Decls : List_Id) return Node_Id; -- Build call to To_Any attribute function with expression as actual - -- parameter. Decls is the declarations list for an appropriate - -- enclosing scope of the point where the call will be inserted; if - -- the To_Any attribute for Typ needs to be generated at this point, - -- its declaration is appended to Decls. + -- parameter. Loc is the reference location for generated nodes, Decls is + -- the declarations list for an appropriate enclosing scope of the point + -- where the call will be inserted; if the To_Any attribute for Typ needs + -- to be generated at this point, its declaration is appended to Decls. function Build_TypeCode_Call (Loc : Source_Ptr;