From: charlet Date: Thu, 17 Jul 2014 07:02:51 +0000 (+0000) Subject: 2014-07-17 Ed Schonberg X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=199ab4c36db38a75d5d1cb9361ac80bd27e9164d;p=thirdparty%2Fgcc.git 2014-07-17 Ed Schonberg * exp_ch9.adb (Buid_Protected_Subprogram_Call): Preserve type of function call for later use when shared passive objects are involved. 2014-07-17 Hristian Kirtchev * par-ch13.adb (Get_Aspect_Specifications): Catch a case where the argument of SPARK aspect Refined_State is not properly parenthesized. 2014-07-17 Hristian Kirtchev * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not extend the lifetime of a reference to an Ada 2012 container element. (Is_Element_Reference): New routine. 2014-07-17 Robert Dewar * ali.ads: Minor comment fix. * lib-writ.adb: Minor reformatting. 2014-07-17 Ed Schonberg * sem_ch10.adb (Analyze_Proper_Body): When analyzing a subunit in ASIS mode, load another subunit only if it a subunit of the current one, not a sibling that has been reached through the analysis of an ancestor. This allows the construction of the ASIS tree for the subunit even when sibling subunits have errors. 2014-07-17 Hristian Kirtchev * sem_ch3.adb (Analyze_Declarations): Remove the guard which prevents the analysis of various contracts when the associated construct is erroneous. * sem_util.adb (Save_SPARK_Mode_And_Set): Do not query the SPARK_Pragma of an illegal or a partially decorated construct. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212734 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d2381cdfcd05..cb09d4807c70 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,42 @@ +2014-07-17 Ed Schonberg + + * exp_ch9.adb (Buid_Protected_Subprogram_Call): Preserve type + of function call for later use when shared passive objects + are involved. + +2014-07-17 Hristian Kirtchev + + * par-ch13.adb (Get_Aspect_Specifications): + Catch a case where the argument of SPARK aspect Refined_State + is not properly parenthesized. + +2014-07-17 Hristian Kirtchev + + * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not extend + the lifetime of a reference to an Ada 2012 container element. + (Is_Element_Reference): New routine. + +2014-07-17 Robert Dewar + + * ali.ads: Minor comment fix. + * lib-writ.adb: Minor reformatting. + +2014-07-17 Ed Schonberg + + * sem_ch10.adb (Analyze_Proper_Body): When analyzing a subunit + in ASIS mode, load another subunit only if it a subunit of the + current one, not a sibling that has been reached through the + analysis of an ancestor. This allows the construction of the + ASIS tree for the subunit even when sibling subunits have errors. + +2014-07-17 Hristian Kirtchev + + * sem_ch3.adb (Analyze_Declarations): Remove the guard which + prevents the analysis of various contracts when the associated + construct is erroneous. + * sem_util.adb (Save_SPARK_Mode_And_Set): Do not query the + SPARK_Pragma of an illegal or a partially decorated construct. + 2014-07-17 Robert Dewar * s-imguns.ads: Minor reformatting. diff --git a/gcc/ada/ali.ads b/gcc/ada/ali.ads index 2c800e732830..d95d01d2e34c 100644 --- a/gcc/ada/ali.ads +++ b/gcc/ada/ali.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -289,7 +289,7 @@ package ALI is Set_Elab_Entity : Boolean; -- Indicates presence of EE parameter for a unit which has an -- elaboration entity which must be set true as part of the - -- elaboration of the entity. + -- elaboration of the unit. Has_RACW : Boolean; -- Indicates presence of RA parameter for a package that declares at diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 374e26f7cbbc..4c8e94876f41 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -4195,6 +4195,33 @@ package body Exp_Ch6 is ------------------------------- procedure Expand_Ctrl_Function_Call (N : Node_Id) is + function Is_Element_Reference (N : Node_Id) return Boolean; + -- Determine whether node N denotes a reference to an Ada 2012 container + -- element. + + -------------------------- + -- Is_Element_Reference -- + -------------------------- + + function Is_Element_Reference (N : Node_Id) return Boolean is + Ref : constant Node_Id := Original_Node (N); + + begin + -- Analysis marks an element reference by setting the generalized + -- indexing attribute of an indexed component before the component + -- is rewritten into a function call. + + return + Nkind (Ref) = N_Indexed_Component + and then Present (Generalized_Indexing (Ref)); + end Is_Element_Reference; + + -- Local variables + + Is_Elem_Ref : constant Boolean := Is_Element_Reference (N); + + -- Start of processing for Expand_Ctrl_Function_Call + begin -- Optimization, if the returned value (which is on the sec-stack) is -- returned again, no need to copy/readjust/finalize, we can just pass @@ -4216,12 +4243,17 @@ package body Exp_Ch6 is Remove_Side_Effects (N); - -- When the temporary function result appears inside a case or an if - -- expression, its lifetime must be extended to match that of the - -- context. If not, the function result would be finalized prematurely - -- and the evaluation of the expression could yield the wrong result. - - if Within_Case_Or_If_Expression (N) + -- When the temporary function result appears inside a case expression + -- or an if expression, its lifetime must be extended to match that of + -- the context. If not, the function result will be finalized too early + -- and the evaluation of the expression could yield incorrect result. An + -- exception to this rule are references to Ada 2012 container elements. + -- Such references must be finalized at the end of each iteration of the + -- related quantified expression, otherwise the container will remain + -- busy. + + if not Is_Elem_Ref + and then Within_Case_Or_If_Expression (N) and then Nkind (N) = N_Explicit_Dereference then Set_Is_Processed_Transient (Entity (Prefix (N))); diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index c5bd57a4432f..8faf3347ba37 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -4379,6 +4379,12 @@ package body Exp_Ch9 is Make_Function_Call (Loc, Name => New_Sub, Parameter_Associations => Params)); + + -- Preserve type of call for subsequent processing (required for + -- call to Wrap_Transient_Expression in the case of a shared passive + -- protected). + + Set_Etype (N, Etype (New_Sub)); end if; if External diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index cdddcf33c900..44dc4150c62d 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -428,10 +428,8 @@ package body Lib.Writ is -- If this is a spec ... if (Is_Subprogram (Uent) - or else - Ekind (Uent) = E_Package - or else - Is_Generic_Unit (Uent)) + or else Ekind (Uent) = E_Package + or else Is_Generic_Unit (Uent)) -- and an elaboration entity was declared ... diff --git a/gcc/ada/par-ch13.adb b/gcc/ada/par-ch13.adb index fffa594d6261..387c83ef8391 100644 --- a/gcc/ada/par-ch13.adb +++ b/gcc/ada/par-ch13.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -308,8 +308,8 @@ package body Ch13 is end if; -- Detect a common error where the non-null definition of - -- aspect Depends, Global, Refined_Depends or Refined_Global - -- must be enclosed in parentheses. + -- aspect Depends, Global, Refined_Depends, Refined_Global + -- or Refined_State lacks enclosing parentheses. if Token /= Tok_Left_Paren and then Token /= Tok_Null then @@ -400,6 +400,48 @@ package body Ch13 is Restore_Scan_State (Scan_State); end if; end; + + -- Refined_State + + elsif A_Id = Aspect_Refined_State then + if Token = Tok_Identifier then + declare + Scan_State : Saved_Scan_State; + + begin + Save_Scan_State (Scan_State); + Scan; -- past state + + -- The refinement contains a constituent, the whole + -- argument of Refined_State must be parenthesized. + + -- with Refined_State => State => Constit + + if Token = Tok_Arrow then + Restore_Scan_State (Scan_State); + Error_Msg_SC -- CODEFIX + ("missing ""("""); + Resync_Past_Malformed_Aspect; + + -- Return when the current aspect is the last + -- in the list of specifications and the list + -- applies to a body. + + if Token = Tok_Is then + return Aspects; + end if; + + -- The refinement lacks constituents. Do not flag + -- this case as the error would be misleading. The + -- diagnostic is left to the analysis. + + -- with Refined_State => State + + else + Restore_Scan_State (Scan_State); + end if; + end; + end if; end if; end if; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 538746e7363f..8330c427da13 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -1703,12 +1703,16 @@ package body Sem_Ch10 is -- If the main unit is a subunit, then we are just performing semantic -- analysis on that subunit, and any other subunits of any parent unit -- should be ignored, except that if we are building trees for ASIS - -- usage we want to annotate the stub properly. + -- usage we want to annotate the stub properly. If the main unit is + -- itself a subunit, another subunit is irrelevant unless it is a + -- subunit of the current one. elsif Nkind (Unit (Cunit (Main_Unit))) = N_Subunit and then Subunit_Name /= Unit_Name (Main_Unit) then - if ASIS_Mode then + if ASIS_Mode + and then Scope (Defining_Entity (N)) = Cunit_Entity (Main_Unit) + then Optional_Subunit; end if; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index b6023637575d..1a02abf2ffcb 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2366,14 +2366,11 @@ package body Sem_Ch3 is -- Analyze the contracts of subprogram declarations, subprogram bodies -- and variables now due to the delayed visibility requirements of their - -- aspects. Skip analysis if the declaration already has an error. + -- aspects. Decl := First (L); while Present (Decl) loop - if Error_Posted (Decl) then - null; - - elsif Nkind (Decl) = N_Object_Declaration then + if Nkind (Decl) = N_Object_Declaration then Analyze_Object_Contract (Defining_Entity (Decl)); elsif Nkind_In (Decl, N_Abstract_Subprogram_Declaration, diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index b57d6f52b643..709a548ef14f 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -15672,17 +15672,18 @@ package body Sem_Util is (Context : Entity_Id; Mode : out SPARK_Mode_Type) is - Prag : constant Node_Id := SPARK_Pragma (Context); - begin -- Save the current mode in effect Mode := SPARK_Mode; - -- Set the mode of the context as the current SPARK mode + -- Do not consider illegal or partially decorated constructs + + if Ekind (Context) = E_Void or else Error_Posted (Context) then + null; - if Present (Prag) then - SPARK_Mode := Get_SPARK_Mode_From_Pragma (Prag); + elsif Present (SPARK_Pragma (Context)) then + SPARK_Mode := Get_SPARK_Mode_From_Pragma (SPARK_Pragma (Context)); end if; end Save_SPARK_Mode_And_Set;