Patchwork [Ada] Get rid of internal use of N_Return_Statement

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 2, 2012, 12:18 p.m.
Message ID <20121002121828.GA15350@adacore.com>
Download mbox | patch
Permalink /patch/188473/
State New
Headers show

Comments

Arnaud Charlet - Oct. 2, 2012, 12:18 p.m.
This patch goes almost all the way in removing N_Return_Statement,
and replacing it by N_Simple_Return_Statement. No test, since no
functional effect.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-10-02  Robert Dewar  <dewar@adacore.com>

	* sinfo.adb, sinfo.ads, sem_util.adb, sem_util.ads, types.h,
	exp_ch4.adb, exp_ch6.adb: Get rid of internal use of N_Return_Statement.

Patch

Index: sinfo.adb
===================================================================
--- sinfo.adb	(revision 191972)
+++ sinfo.adb	(working copy)
@@ -370,7 +370,7 @@ 
    begin
       pragma Assert (False
         or else NT (N).Nkind = N_Extended_Return_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       return Flag5 (N);
    end By_Ref;
 
@@ -427,7 +427,7 @@ 
      (N : Node_Id) return Boolean is
    begin
       pragma Assert (False
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       return Flag18 (N);
    end Comes_From_Extended_Return_Statement;
 
@@ -958,7 +958,7 @@ 
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Function_Call
         or else NT (N).Nkind = N_Procedure_Call_Statement
-        or else NT (N).Nkind = N_Return_Statement
+        or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion);
       return Flag13 (N);
    end Do_Tag_Check;
@@ -1234,7 +1234,7 @@ 
         or else NT (N).Nkind = N_Pragma_Argument_Association
         or else NT (N).Nkind = N_Qualified_Expression
         or else NT (N).Nkind = N_Raise_Statement
-        or else NT (N).Nkind = N_Return_Statement
+        or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion
         or else NT (N).Nkind = N_Unchecked_Expression
         or else NT (N).Nkind = N_Unchecked_Type_Conversion);
@@ -2537,7 +2537,7 @@ 
         or else NT (N).Nkind = N_Allocator
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Free_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       return Node2 (N);
    end Procedure_To_Call;
 
@@ -2670,7 +2670,7 @@ 
    begin
       pragma Assert (False
         or else NT (N).Nkind = N_Extended_Return_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       return Node5 (N);
    end Return_Statement_Entity;
 
@@ -2862,7 +2862,7 @@ 
         or else NT (N).Nkind = N_Allocator
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Free_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       return Node1 (N);
    end Storage_Pool;
 
@@ -3443,7 +3443,7 @@ 
    begin
       pragma Assert (False
         or else NT (N).Nkind = N_Extended_Return_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       Set_Flag5 (N, Val);
    end Set_By_Ref;
 
@@ -3500,7 +3500,7 @@ 
      (N : Node_Id; Val : Boolean := True) is
    begin
       pragma Assert (False
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       Set_Flag18 (N, Val);
    end Set_Comes_From_Extended_Return_Statement;
 
@@ -4031,7 +4031,7 @@ 
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Function_Call
         or else NT (N).Nkind = N_Procedure_Call_Statement
-        or else NT (N).Nkind = N_Return_Statement
+        or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion);
       Set_Flag13 (N, Val);
    end Set_Do_Tag_Check;
@@ -4298,7 +4298,7 @@ 
         or else NT (N).Nkind = N_Pragma_Argument_Association
         or else NT (N).Nkind = N_Qualified_Expression
         or else NT (N).Nkind = N_Raise_Statement
-        or else NT (N).Nkind = N_Return_Statement
+        or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion
         or else NT (N).Nkind = N_Unchecked_Expression
         or else NT (N).Nkind = N_Unchecked_Type_Conversion);
@@ -5601,7 +5601,7 @@ 
         or else NT (N).Nkind = N_Allocator
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Free_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       Set_Node2 (N, Val); -- semantic field, no parent set
    end Set_Procedure_To_Call;
 
@@ -5734,7 +5734,7 @@ 
    begin
       pragma Assert (False
         or else NT (N).Nkind = N_Extended_Return_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       Set_Node5 (N, Val); -- semantic field, no parent set
    end Set_Return_Statement_Entity;
 
@@ -5926,7 +5926,7 @@ 
         or else NT (N).Nkind = N_Allocator
         or else NT (N).Nkind = N_Extended_Return_Statement
         or else NT (N).Nkind = N_Free_Statement
-        or else NT (N).Nkind = N_Return_Statement);
+        or else NT (N).Nkind = N_Simple_Return_Statement);
       Set_Node1 (N, Val); -- semantic field, no parent set
    end Set_Storage_Pool;
 
Index: sinfo.ads
===================================================================
--- sinfo.ads	(revision 191973)
+++ sinfo.ads	(working copy)
@@ -4799,10 +4799,6 @@ 
       -- 6.5  Return Statement --
       ---------------------------
 
-      --  RETURN_STATEMENT ::= return [EXPRESSION]; -- Ada 95
-
-      --  In Ada 2005, we have:
-
       --  SIMPLE_RETURN_STATEMENT ::= return [EXPRESSION];
 
       --  EXTENDED_RETURN_STATEMENT ::=
@@ -4813,11 +4809,12 @@ 
 
       --  RETURN_SUBTYPE_INDICATION ::= SUBTYPE_INDICATION | ACCESS_DEFINITION
 
-      --  So in Ada 2005, RETURN_STATEMENT is no longer a nonterminal, but
-      --  "return statement" is defined in 6.5 to mean a
-      --  SIMPLE_RETURN_STATEMENT or an EXTENDED_RETURN_STATEMENT.
+      --  The term "return statement" is defined in 6.5 to mean either a
+      --  SIMPLE_RETURN_STATEMENT or an EXTENDED_RETURN_STATEMENT. We avoid
+      --  the use of this term, since it used to mean someting else in earlier
+      --  versions of Ada.
 
-      --  N_Return_Statement
+      --  N_Simple_Return_Statement
       --  Sloc points to RETURN
       --  Return_Statement_Entity (Node5-Sem)
       --  Expression (Node3) (set to Empty if no expression present)
@@ -4827,12 +4824,6 @@ 
       --  By_Ref (Flag5-Sem)
       --  Comes_From_Extended_Return_Statement (Flag18-Sem)
 
-      --  N_Return_Statement represents a simple_return_statement, and is
-      --  renamed to be N_Simple_Return_Statement below. Clients should refer
-      --  to N_Simple_Return_Statement. We retain N_Return_Statement because
-      --  that's how gigi knows it. See also renaming of Make_Return_Statement
-      --  as Make_Simple_Return_Statement in Sem_Util.
-
       --  Note: Return_Statement_Entity points to an E_Return_Statement
 
       --  If a range check is required, then Do_Range_Check is set on the
@@ -7785,7 +7776,7 @@ 
       N_Null_Statement,
       N_Raise_Statement,
       N_Requeue_Statement,
-      N_Return_Statement, -- renamed as N_Simple_Return_Statement below
+      N_Simple_Return_Statement,
       N_Extended_Return_Statement,
       N_Selective_Accept,
       N_Timed_Entry_Call,
@@ -10942,7 +10933,7 @@ 
         4 => False,   --  Next_Named_Actual (Node4-Sem)
         5 => False),  --  unused
 
-     N_Return_Statement =>
+     N_Simple_Return_Statement =>
        (1 => False,   --  Storage_Pool (Node1-Sem)
         2 => False,   --  Procedure_To_Call (Node2-Sem)
         3 => True,    --  Expression (Node3)
@@ -12435,8 +12426,8 @@ 
    --  These synonyms are to aid in transition, they should eventually be
    --  removed when all remaining references to the obsolete name are gone.
 
-   N_Simple_Return_Statement : constant Node_Kind := N_Return_Statement;
-   --  Rename N_Return_Statement to be N_Simple_Return_Statement. Clients
+   N_Return_Statement : constant Node_Kind := N_Simple_Return_Statement;
+   --  Rename N_Simple_Return_Statement to be N_Return_Statement. Clients
    --  should refer to N_Simple_Return_Statement.
 
 end Sinfo;
Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 191972)
+++ sem_util.adb	(working copy)
@@ -37,6 +37,7 @@ 
 with Lib;      use Lib;
 with Lib.Xref; use Lib.Xref;
 with Nlists;   use Nlists;
+with Nmake;    use Nmake;
 with Output;   use Output;
 with Opt;      use Opt;
 with Restrict; use Restrict;
Index: sem_util.ads
===================================================================
--- sem_util.ads	(revision 191972)
+++ sem_util.ads	(working copy)
@@ -28,7 +28,6 @@ 
 with Einfo;   use Einfo;
 with Exp_Tss; use Exp_Tss;
 with Namet;   use Namet;
-with Nmake;   use Nmake;
 with Snames;  use Snames;
 with Types;   use Types;
 with Uintp;   use Uintp;
@@ -1093,13 +1092,6 @@ 
    --  statement in Statements (HSS) that has Comes_From_Source set. If no
    --  such statement exists, Empty is returned.
 
-   function Make_Simple_Return_Statement
-     (Sloc       : Source_Ptr;
-      Expression : Node_Id := Empty) return Node_Id
-     renames Make_Return_Statement;
-   --  See Sinfo. We rename Make_Return_Statement to the correct Ada 2005
-   --  terminology here. Clients should use Make_Simple_Return_Statement.
-
    function Matching_Static_Array_Bounds
      (L_Typ : Node_Id;
       R_Typ : Node_Id) return Boolean;
@@ -1107,15 +1099,6 @@ 
    --  same number of dimensions, and the same static bounds for each index
    --  position.
 
-   Make_Return_Statement : constant := -2 ** 33;
-   --  Attempt to prevent accidental uses of Make_Return_Statement. If this
-   --  and the one in Nmake are both potentially use-visible, it will cause
-   --  a compilation error. Note that type and value are irrelevant.
-
-   N_Return_Statement : constant := -2 ** 33;
-   --  Attempt to prevent accidental uses of N_Return_Statement; similar to
-   --  Make_Return_Statement above.
-
    procedure Mark_Coextensions (Context_Nod : Node_Id; Root_Nod : Node_Id);
    --  Given a node which designates the context of analysis and an origin in
    --  the tree, traverse from Root_Nod and mark all allocators as either
Index: types.h
===================================================================
--- types.h	(revision 191973)
+++ types.h	(working copy)
@@ -384,3 +384,6 @@ 
 #define SE_Object_Too_Large                34
 
 #define LAST_REASON_CODE                   34
+
+#define N_Return_Statement N_Simple_Return_Statement
+/* temporary synonym for transition */
Index: exp_ch4.adb
===================================================================
--- exp_ch4.adb	(revision 191972)
+++ exp_ch4.adb	(working copy)
@@ -10006,7 +10006,7 @@ 
                --  of the object designated by the result value identifies T.
                --  Constraint_Error is raised if this check fails.
 
-               if Nkind (Parent (N)) = Sinfo.N_Return_Statement then
+               if Nkind (Parent (N)) = N_Simple_Return_Statement then
                   declare
                      Func     : Entity_Id;
                      Func_Typ : Entity_Id;
Index: exp_ch6.adb
===================================================================
--- exp_ch6.adb	(revision 191972)
+++ exp_ch6.adb	(working copy)
@@ -4781,31 +4781,31 @@ 
             else
                pragma Assert
                  (Nkind
-                    (First
-                       (Statements (Handled_Statement_Sequence (Orig_Bod))))
+                   (First
+                     (Statements (Handled_Statement_Sequence (Orig_Bod))))
                   = N_Block_Statement);
 
                declare
                   Blk_Stmt    : constant Node_Id :=
                     First
                       (Statements
-                           (Handled_Statement_Sequence (Orig_Bod)));
+                        (Handled_Statement_Sequence (Orig_Bod)));
                   First_Stmt  : constant Node_Id :=
                     First
                       (Statements
-                           (Handled_Statement_Sequence (Blk_Stmt)));
+                        (Handled_Statement_Sequence (Blk_Stmt)));
                   Second_Stmt : constant Node_Id := Next (First_Stmt);
 
                begin
                   pragma Assert
                     (Nkind (First_Stmt) = N_Procedure_Call_Statement
-                       and then Nkind (Second_Stmt) = Sinfo.N_Return_Statement
-                       and then No (Next (Second_Stmt)));
+                      and then Nkind (Second_Stmt) = N_Simple_Return_Statement
+                      and then No (Next (Second_Stmt)));
 
                   Bod :=
                     Copy_Generic_Node
                       (First
-                         (Statements (Handled_Statement_Sequence (Orig_Bod))),
+                        (Statements (Handled_Statement_Sequence (Orig_Bod))),
                        Empty, Instantiating => True);
                   Blk := Bod;
 
@@ -5129,8 +5129,8 @@ 
          --  Remove the return statement
 
          pragma Assert
-           (Nkind (Last (Statements (Handled_Statement_Sequence (Blk))))
-            = Sinfo.N_Return_Statement);
+           (Nkind (Last (Statements (Handled_Statement_Sequence (Blk)))) =
+                                                   N_Simple_Return_Statement);
 
          Remove (Last (Statements (Handled_Statement_Sequence (Blk))));
       end if;