[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 15 Mar 2012 09:09:31 +0000 (10:09 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 15 Mar 2012 09:09:31 +0000 (10:09 +0100)
2012-03-15  Vincent Pucci  <pucci@adacore.com>

* sem_ch4.adb (Analyze_Quantified_Expression):
Preanalyze the condition when the quantified expression will be
further expanded.

2012-03-15  Yannick Moy  <moy@adacore.com>

* sem_prag.adb, sem_util.adb, sem_util.ads, sem_attr.adb, sem_ch6.adb,
sem_warn.adb: Minor refactoring, renaming Case_Pragma in CTC_Pragma,
to refer to both Test_Case pragma and Contract_Case pragma (same
acronym as in Spec_CTC_List).

From-SVN: r185419

gcc/ada/ChangeLog
gcc/ada/sem_attr.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/ada/sem_warn.adb

index c9063a650f0cca59f68127bc75b83a6bf9882045..45a53bbd88a4272fc791c9d8c73992c989f7f6aa 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-15  Vincent Pucci  <pucci@adacore.com>
+
+       * sem_ch4.adb (Analyze_Quantified_Expression):
+       Preanalyze the condition when the quantified expression will be
+       further expanded.
+
+2012-03-15  Yannick Moy  <moy@adacore.com>
+
+       * sem_prag.adb, sem_util.adb, sem_util.ads, sem_attr.adb, sem_ch6.adb,
+       sem_warn.adb: Minor refactoring, renaming Case_Pragma in CTC_Pragma,
+       to refer to both Test_Case pragma and Contract_Case pragma (same
+       acronym as in Spec_CTC_List).
+
 2012-03-15  Robert Dewar  <dewar@adacore.com>
 
        * sem_prag.adb, sem_prag.ads, sem_util.ads, sem_attr.adb, sem_ch6.adb,
index d5164865df407acbfb6136ff63272c8d18e3f038..50c7d1242ec05c57d3a24de81a9f73146edd8737 100644 (file)
@@ -4260,7 +4260,7 @@ package body Sem_Attr is
             then
                declare
                   Arg_Ens : constant Node_Id :=
-                              Get_Ensures_From_Case_Pragma (Prag);
+                              Get_Ensures_From_CTC_Pragma (Prag);
                   Arg     : Node_Id;
 
                begin
index c6f8c0c1f07d16d3b4adceff98ef5e641c1fd441..55674855ab3ad9ad1fb7a2849e1a2e27fc105e6a 100644 (file)
@@ -29,6 +29,7 @@ with Debug;    use Debug;
 with Einfo;    use Einfo;
 with Elists;   use Elists;
 with Errout;   use Errout;
+with Expander; use Expander;
 with Exp_Util; use Exp_Util;
 with Fname;    use Fname;
 with Itypes;   use Itypes;
@@ -3442,7 +3443,19 @@ package body Sem_Ch4 is
          Set_Parent (Iterator_Specification (Iterator), Iterator);
       end if;
 
-      Analyze (Condition (N));
+      if Needs_Expansion then
+
+         --  The full analysis will be performed during the expansion of the
+         --  quantified expression, only a preanalysis of the condition needs
+         --  to be done.
+
+         Expander_Mode_Save_And_Set (False);
+         Analyze (Condition (N));
+         Expander_Mode_Restore;
+      else
+         Analyze (Condition (N));
+      end if;
+
       End_Scope;
 
       Set_Etype (N, Standard_Boolean);
index 391ac8034e5813f5177b2662e0c7421ffc58eac3..a63cb7944b797455ea71d8cd55e1d4f333db193d 100644 (file)
@@ -7079,7 +7079,7 @@ package body Sem_Ch6 is
          loop
             --  Retrieve the Ensures component of the contract-case, if any
 
-            Arg := Get_Ensures_From_Case_Pragma (Prag);
+            Arg := Get_Ensures_From_CTC_Pragma (Prag);
 
             if Pragma_Name (Prag) = Name_Contract_Case then
 
@@ -11058,11 +11058,11 @@ package body Sem_Ch6 is
          --  Copy the Requires and Ensures expressions
 
          Req  := New_Copy_Tree
-                   (Expression (Get_Requires_From_Case_Pragma (Prag)),
+                   (Expression (Get_Requires_From_CTC_Pragma (Prag)),
                     New_Scope => Current_Scope);
 
          Ens  := New_Copy_Tree
-                   (Expression (Get_Ensures_From_Case_Pragma (Prag)),
+                   (Expression (Get_Ensures_From_CTC_Pragma (Prag)),
                     New_Scope => Current_Scope);
 
          --  Build the postcondition (not Requires'Old or else Ensures)
index 51ca907a3817187604936a7222d5eb9da41f8004..38a2c8c4a05603026d353bf7357b69963f18141c 100644 (file)
@@ -260,8 +260,8 @@ package body Sem_Prag is
 
       Preanalyze_CTC_Args
         (N,
-         Get_Requires_From_Case_Pragma (N),
-         Get_Ensures_From_Case_Pragma (N));
+         Get_Requires_From_CTC_Pragma (N),
+         Get_Ensures_From_CTC_Pragma (N));
 
       --  Remove the subprogram from the scope stack now that the pre-analysis
       --  of the expressions in the contract case or test case is done.
@@ -1465,13 +1465,13 @@ package body Sem_Prag is
             --  same name associated to this subprogram.
 
             declare
-               Name : constant String_Id := Get_Name_From_Case_Pragma (N);
+               Name : constant String_Id := Get_Name_From_CTC_Pragma (N);
                CTC  : Node_Id;
 
             begin
                CTC := Spec_CTC_List (Contract (S));
                while Present (CTC) loop
-                  if String_Equal (Name, Get_Name_From_Case_Pragma (CTC)) then
+                  if String_Equal (Name, Get_Name_From_CTC_Pragma (CTC)) then
                      Error_Msg_Sloc := Sloc (CTC);
                      Error_Pragma ("name for pragma% is already used#");
                   end if;
index 1d600307ecaf388f421dc391ea86e327eecc8a2c..6519221cbe67b4441c83132d7a43a37bbe37b7ab 100644 (file)
@@ -4490,11 +4490,11 @@ package body Sem_Util is
       end if;
    end Get_Enum_Lit_From_Pos;
 
-   ----------------------------------
-   -- Get_Ensures_From_Case_Pragma --
-   ----------------------------------
+   ---------------------------------
+   -- Get_Ensures_From_CTC_Pragma --
+   ---------------------------------
 
-   function Get_Ensures_From_Case_Pragma (N : Node_Id) return Node_Id is
+   function Get_Ensures_From_CTC_Pragma (N : Node_Id) return Node_Id is
       Args : constant List_Id := Pragma_Argument_Associations (N);
       Res  : Node_Id;
 
@@ -4514,7 +4514,7 @@ package body Sem_Util is
       end if;
 
       return Res;
-   end Get_Ensures_From_Case_Pragma;
+   end Get_Ensures_From_CTC_Pragma;
 
    ------------------------
    -- Get_Generic_Entity --
@@ -4602,16 +4602,16 @@ package body Sem_Util is
       return Entity_Id (Get_Name_Table_Info (Id));
    end Get_Name_Entity_Id;
 
-   -------------------------------
-   -- Get_Name_From_Case_Pragma --
-   -------------------------------
+   ------------------------------
+   -- Get_Name_From_CTC_Pragma --
+   ------------------------------
 
-   function Get_Name_From_Case_Pragma (N : Node_Id) return String_Id is
+   function Get_Name_From_CTC_Pragma (N : Node_Id) return String_Id is
       Arg : constant Node_Id :=
               Get_Pragma_Arg (First (Pragma_Argument_Associations (N)));
    begin
       return Strval (Expr_Value_S (Arg));
-   end Get_Name_From_Case_Pragma;
+   end Get_Name_From_CTC_Pragma;
 
    -------------------
    -- Get_Pragma_Id --
@@ -4656,11 +4656,11 @@ package body Sem_Util is
       return R;
    end Get_Renamed_Entity;
 
-   -----------------------------------
-   -- Get_Requires_From_Case_Pragma --
-   -----------------------------------
+   ----------------------------------
+   -- Get_Requires_From_CTC_Pragma --
+   ----------------------------------
 
-   function Get_Requires_From_Case_Pragma (N : Node_Id) return Node_Id is
+   function Get_Requires_From_CTC_Pragma (N : Node_Id) return Node_Id is
       Args : constant List_Id := Pragma_Argument_Associations (N);
       Res  : Node_Id;
 
@@ -4677,7 +4677,7 @@ package body Sem_Util is
       end if;
 
       return Res;
-   end Get_Requires_From_Case_Pragma;
+   end Get_Requires_From_CTC_Pragma;
 
    -------------------------
    -- Get_Subprogram_Body --
index 898222805b1fe7bcc28c80c9fd9361279bd458ea..34d2fc0383c2e51b41abc3c698344280d437bf70 100644 (file)
@@ -538,7 +538,7 @@ package Sem_Util is
    --  If expression N references a part of an object, return this object.
    --  Otherwise return Empty. Expression N should have been resolved already.
 
-   function Get_Ensures_From_Case_Pragma (N : Node_Id) return Node_Id;
+   function Get_Ensures_From_CTC_Pragma (N : Node_Id) return Node_Id;
    --  Return the Ensures component of Contract_Case or Test_Case pragma N, or
    --  Empty otherwise.
 
@@ -573,9 +573,8 @@ package Sem_Util is
    --  is the innermost visible entity with the given name. See the body of
    --  Sem_Ch8 for further details on handling of entity visibility.
 
-   function Get_Name_From_Case_Pragma (N : Node_Id) return String_Id;
+   function Get_Name_From_CTC_Pragma (N : Node_Id) return String_Id;
    --  Return the Name component of Contract_Case or Test_Case pragma N
-   --  Bad name, Case_Pragma is meaningless to me ???
 
    function Get_Pragma_Id (N : Node_Id) return Pragma_Id;
    pragma Inline (Get_Pragma_Id);
@@ -592,7 +591,7 @@ package Sem_Util is
    --  not a renamed entity, returns its argument. It is an error to call this
    --  with any other kind of entity.
 
-   function Get_Requires_From_Case_Pragma (N : Node_Id) return Node_Id;
+   function Get_Requires_From_CTC_Pragma (N : Node_Id) return Node_Id;
    --  Return the Requires component of Contract_Case or Test_Case pragma N, or
    --  Empty otherwise.
 
index 129eb35a9fb51dbd49a16f38b58754b081b26b22..3ba8b9116cdbf0315ce5d41936802e2c56198e20 100644 (file)
@@ -1775,7 +1775,7 @@ package body Sem_Warn is
                                      or else
                                    Pragma_Name (P) = Name_Test_Case)
                                 and then
-                                  Nod = Get_Ensures_From_Case_Pragma (P)
+                                  Nod = Get_Ensures_From_CTC_Pragma (P)
                               then
                                  return True;
                               end if;