]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2014-07-17 Ed Schonberg <schonberg@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jul 2014 07:02:51 +0000 (07:02 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jul 2014 07:02:51 +0000 (07:02 +0000)
* 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  <kirtchev@adacore.com>

* 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  <kirtchev@adacore.com>

* 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  <dewar@adacore.com>

* ali.ads: Minor comment fix.
* lib-writ.adb: Minor reformatting.

2014-07-17  Ed Schonberg  <schonberg@adacore.com>

* 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  <kirtchev@adacore.com>

* 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

gcc/ada/ChangeLog
gcc/ada/ali.ads
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch9.adb
gcc/ada/lib-writ.adb
gcc/ada/par-ch13.adb
gcc/ada/sem_ch10.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb

index d2381cdfcd05e00a5f467b7b15a0a3f89c134a6e..cb09d4807c70717bd6a0fc07b6ac8e4877db7526 100644 (file)
@@ -1,3 +1,42 @@
+2014-07-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <kirtchev@adacore.com>
+
+       * 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  <kirtchev@adacore.com>
+
+       * 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  <dewar@adacore.com>
+
+       * ali.ads: Minor comment fix.
+       * lib-writ.adb: Minor reformatting.
+
+2014-07-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <kirtchev@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * s-imguns.ads: Minor reformatting.
index 2c800e732830f69ac4a6287fd7a296e12162e5c6..d95d01d2e34c57181305b8160e600fcd4d392ced 100644 (file)
@@ -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
index 374e26f7cbbc124ab330d1efe7b76a2250f38d5e..4c8e94876f41ebb96dfe0a7e08d37d71f22696ff 100644 (file)
@@ -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)));
index c5bd57a4432f73847e2662fade878cbfeea73602..8faf3347ba375f9e96e2527344f819970601f3b9 100644 (file)
@@ -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
index cdddcf33c9004f93c71dbef6951ba16031b77391..44dc4150c62d579e46bb37a8a7a4093880890834 100644 (file)
@@ -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 ...
 
index fffa594d6261944dfddd987905c2f5bbb5ca5d59..387c83ef83913d71987bd3c04dde520223985550 100644 (file)
@@ -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;
 
index 538746e7363f6e44a94607638c8eeea2d81b519a..8330c427da133e25be3834f942fb46eca22991db 100644 (file)
@@ -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;
 
index b6023637575deae8c2663c712dec2a9e33c5bb66..1a02abf2ffcb037c5d36ad75b45fc875585f163a 100644 (file)
@@ -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,
index b57d6f52b6438f32e2971abe31ea6cac29ccec7f..709a548ef14faf01894541f7d978a52daa4f972c 100644 (file)
@@ -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;