Patchwork [Ada] Use Make_Temporary (4)

login
register
mail settings
Submitter Arnaud Charlet
Date June 17, 2010, 10:46 a.m.
Message ID <20100617104607.GA28668@adacore.com>
Download mbox | patch
Permalink /patch/56008/
State New
Headers show

Comments

Arnaud Charlet - June 17, 2010, 10:46 a.m.
This patch is another of several that replaces calls to
Make_Defining_Identifier, with calls to Make_Temporary where
possible, setting Node where possible. This is an internal
cleanup that does not affect compiler functionality in any
way, so no test needed.

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

2010-06-17  Robert Dewar  <dewar@adacore.com>

	* exp_fixd.adb, exp_imgv.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb,
	exp_sel.adb, exp_util.adb, sem_ch10.adb, sem_ch12.adb, sem_ch13.adb,
	sem_ch3.adb, sem_ch4.adb, sem_ch5.adb, sem_ch8.adb, sem_ch9.adb,
	sem_dist.adb, sem_util.adb: Use Make_Temporary
	* itypes.ads, tbuild.ads: Minor comment update
	* exp_ch9.adb, exp_dist.adb: Minor reformatting

Patch

Index: exp_prag.adb
===================================================================
--- exp_prag.adb	(revision 160834)
+++ exp_prag.adb	(working copy)
@@ -536,17 +536,14 @@  package body Exp_Prag is
       begin
          if Present (Call) then
             declare
-               Excep_Internal : constant Node_Id :=
-                                 Make_Defining_Identifier
-                                  (Loc, New_Internal_Name ('V'));
-
-               Export_Pragma : Node_Id;
-               Excep_Alias   : Node_Id;
-               Excep_Object  : Node_Id;
-               Excep_Image   : String_Id;
-               Exdata        : List_Id;
-               Lang_Char     : Node_Id;
-               Code          : Node_Id;
+               Excep_Internal : constant Node_Id := Make_Temporary (Loc, 'V');
+               Export_Pragma  : Node_Id;
+               Excep_Alias    : Node_Id;
+               Excep_Object   : Node_Id;
+               Excep_Image    : String_Id;
+               Exdata         : List_Id;
+               Lang_Char      : Node_Id;
+               Code           : Node_Id;
 
             begin
                if Present (Interface_Name (Id)) then
Index: exp_imgv.adb
===================================================================
--- exp_imgv.adb	(revision 160895)
+++ exp_imgv.adb	(working copy)
@@ -260,13 +260,8 @@  package body Exp_Imgv is
       Ins_List : List_Id;
       --  List of actions to be inserted
 
-      Snn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('S'));
-
-      Pnn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('P'));
+      Snn : constant Entity_Id := Make_Temporary (Loc, 'S');
+      Pnn : constant Entity_Id := Make_Temporary (Loc, 'P');
 
    begin
       --  Build declarations of Snn and Pnn to be inserted
@@ -773,14 +768,8 @@  package body Exp_Imgv is
    procedure Expand_Wide_Image_Attribute (N : Node_Id) is
       Loc  : constant Source_Ptr := Sloc (N);
       Rtyp : constant Entity_Id  := Root_Type (Entity (Prefix (N)));
-
-      Rnn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('S'));
-
-      Lnn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('P'));
+      Rnn  : constant Entity_Id := Make_Temporary (Loc, 'S');
+      Lnn  : constant Entity_Id := Make_Temporary (Loc, 'P');
 
    begin
       Insert_Actions (N, New_List (
@@ -871,13 +860,8 @@  package body Exp_Imgv is
       Loc  : constant Source_Ptr := Sloc (N);
       Rtyp : constant Entity_Id  := Root_Type (Entity (Prefix (N)));
 
-      Rnn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('S'));
-
-      Lnn : constant Entity_Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('P'));
+      Rnn : constant Entity_Id := Make_Temporary (Loc, 'S');
+      Lnn : constant Entity_Id := Make_Temporary (Loc, 'P');
 
    begin
       Insert_Actions (N, New_List (
Index: exp_util.adb
===================================================================
--- exp_util.adb	(revision 160834)
+++ exp_util.adb	(working copy)
@@ -398,7 +398,7 @@  package body Exp_Util is
       Pos : Entity_Id;
       --  Running index for substring assignments
 
-      Pref : Entity_Id;
+      Pref : constant Entity_Id := Make_Temporary (Loc, 'P');
       --  Name of enclosing variable, prefix of resulting name
 
       Res : Entity_Id;
@@ -417,8 +417,6 @@  package body Exp_Util is
       Stats : constant List_Id := New_List;
 
    begin
-      Pref := Make_Defining_Identifier (Loc, New_Internal_Name ('P'));
-
       --  For a dynamic task, the name comes from the target variable.
       --  For a static one it is a formal of the enclosing init proc.
 
@@ -444,7 +442,7 @@  package body Exp_Util is
       Val  := First (Expressions (Id_Ref));
 
       for J in 1 .. Dims loop
-         T := Make_Defining_Identifier (Loc, New_Internal_Name ('T'));
+         T := Make_Temporary (Loc, 'T');
          Temps (J) := T;
 
          Append_To (Decls,
@@ -454,10 +452,8 @@  package body Exp_Util is
                Expression =>
                  Make_Attribute_Reference (Loc,
                    Attribute_Name => Name_Image,
-                   Prefix =>
-                     New_Occurrence_Of (Etype (Indx), Loc),
-                   Expressions => New_List (
-                     New_Copy_Tree (Val)))));
+                   Prefix         => New_Occurrence_Of (Etype (Indx), Loc),
+                   Expressions    => New_List (New_Copy_Tree (Val)))));
 
          Next_Index (Indx);
          Next (Val);
@@ -613,7 +609,7 @@  package body Exp_Util is
       if Restriction_Active (No_Implicit_Heap_Allocations)
         or else Global_Discard_Names
       then
-         T_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('J'));
+         T_Id := Make_Temporary (Loc, 'J');
          Name_Len := 0;
 
          return
@@ -697,9 +693,8 @@  package body Exp_Util is
           Expression => New_Occurrence_Of (Res, Loc)));
 
       Spec := Make_Function_Specification (Loc,
-        Defining_Unit_Name =>
-          Make_Defining_Identifier (Loc, New_Internal_Name ('F')),
-        Result_Definition => New_Occurrence_Of (Standard_String, Loc));
+        Defining_Unit_Name => Make_Temporary (Loc, 'F'),
+        Result_Definition  => New_Occurrence_Of (Standard_String, Loc));
 
       --  Calls to 'Image use the secondary stack, which must be cleaned
       --  up after the task name is built.
@@ -726,15 +721,15 @@  package body Exp_Util is
        Stats  : List_Id)
    is
    begin
-      Len := Make_Defining_Identifier (Loc, New_Internal_Name ('L'));
+      Len := Make_Temporary (Loc, 'L', Sum);
 
       Append_To (Decls,
         Make_Object_Declaration (Loc,
           Defining_Identifier => Len,
-          Object_Definition => New_Occurrence_Of (Standard_Integer, Loc),
-          Expression        => Sum));
+          Object_Definition   => New_Occurrence_Of (Standard_Integer, Loc),
+          Expression          => Sum));
 
-      Res := Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
+      Res := Make_Temporary (Loc, 'R');
 
       Append_To (Decls,
          Make_Object_Declaration (Loc,
@@ -750,12 +745,12 @@  package body Exp_Util is
                          Low_Bound => Make_Integer_Literal (Loc, 1),
                          High_Bound => New_Occurrence_Of (Len, Loc)))))));
 
-      Pos := Make_Defining_Identifier (Loc, New_Internal_Name ('P'));
+      Pos := Make_Temporary (Loc, 'P');
 
       Append_To (Decls,
          Make_Object_Declaration (Loc,
             Defining_Identifier => Pos,
-            Object_Definition => New_Occurrence_Of (Standard_Integer, Loc)));
+            Object_Definition   => New_Occurrence_Of (Standard_Integer, Loc)));
 
       --  Pos := Prefix'Length;
 
@@ -765,29 +760,29 @@  package body Exp_Util is
             Expression =>
               Make_Attribute_Reference (Loc,
                 Attribute_Name => Name_Length,
-                Prefix => New_Occurrence_Of (Prefix, Loc),
-                Expressions =>
-                    New_List (Make_Integer_Literal (Loc, 1)))));
+                Prefix         => New_Occurrence_Of (Prefix, Loc),
+                Expressions    => New_List (Make_Integer_Literal (Loc, 1)))));
 
       --  Res (1 .. Pos) := Prefix;
 
       Append_To (Stats,
-         Make_Assignment_Statement (Loc,
-           Name => Make_Slice (Loc,
-              Prefix => New_Occurrence_Of (Res, Loc),
+        Make_Assignment_Statement (Loc,
+          Name =>
+            Make_Slice (Loc,
+              Prefix          => New_Occurrence_Of (Res, Loc),
               Discrete_Range  =>
                 Make_Range (Loc,
-                   Low_Bound => Make_Integer_Literal (Loc, 1),
+                   Low_Bound  => Make_Integer_Literal (Loc, 1),
                    High_Bound => New_Occurrence_Of (Pos, Loc))),
 
-           Expression => New_Occurrence_Of (Prefix, Loc)));
+          Expression => New_Occurrence_Of (Prefix, Loc)));
 
       Append_To (Stats,
          Make_Assignment_Statement (Loc,
-            Name => New_Occurrence_Of (Pos, Loc),
+            Name       => New_Occurrence_Of (Pos, Loc),
             Expression =>
               Make_Op_Add (Loc,
-                Left_Opnd => New_Occurrence_Of (Pos, Loc),
+                Left_Opnd  => New_Occurrence_Of (Pos, Loc),
                 Right_Opnd => Make_Integer_Literal (Loc, 1))));
    end Build_Task_Image_Prefix;
 
@@ -809,7 +804,7 @@  package body Exp_Util is
       Res : Entity_Id;
       --  String to hold result
 
-      Pref : Entity_Id;
+      Pref : constant Entity_Id := Make_Temporary (Loc, 'P');
       --  Name of enclosing variable, prefix of resulting name
 
       Sum : Node_Id;
@@ -822,8 +817,6 @@  package body Exp_Util is
       Stats : constant List_Id := New_List;
 
    begin
-      Pref := Make_Defining_Identifier (Loc, New_Internal_Name ('P'));
-
       --  For a dynamic task, the name comes from the target variable.
       --  For a static one it is a formal of the enclosing init proc.
 
@@ -845,15 +838,15 @@  package body Exp_Util is
              Name                => Make_Identifier (Loc, Name_uTask_Name)));
       end if;
 
-      Sel := Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
+      Sel := Make_Temporary (Loc, 'S');
 
       Get_Name_String (Chars (Selector_Name (Id_Ref)));
 
       Append_To (Decls,
          Make_Object_Declaration (Loc,
            Defining_Identifier => Sel,
-           Object_Definition => New_Occurrence_Of (Standard_String, Loc),
-           Expression =>
+           Object_Definition   => New_Occurrence_Of (Standard_String, Loc),
+           Expression          =>
              Make_String_Literal (Loc,
                Strval => String_From_Name_Buffer)));
 
@@ -1300,9 +1293,7 @@  package body Exp_Util is
             end if;
 
          else
-            T :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('T'));
+            T := Make_Temporary (Loc, 'T');
 
             Insert_Action (N,
               Make_Subtype_Declaration (Loc,
@@ -3758,21 +3749,19 @@  package body Exp_Util is
       if not Has_Discriminants (Root_Typ) then
          Constr_Root := Root_Typ;
       else
-         Constr_Root :=
-           Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
+         Constr_Root := Make_Temporary (Loc, 'R');
 
          --  subtype cstr__n is T (List of discr constraints taken from Exp)
 
          Append_To (List_Def,
            Make_Subtype_Declaration (Loc,
              Defining_Identifier => Constr_Root,
-               Subtype_Indication =>
-                 Make_Subtype_From_Expr (E, Root_Typ)));
+             Subtype_Indication  => Make_Subtype_From_Expr (E, Root_Typ)));
       end if;
 
       --  Generate the range subtype declaration
 
-      Range_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('G'));
+      Range_Type := Make_Temporary (Loc, 'G');
 
       if not Is_Interface (Root_Typ) then
 
@@ -3821,7 +3810,7 @@  package body Exp_Util is
 
       --  subtype str__nn is Storage_Array (rg__x);
 
-      Str_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
+      Str_Type := Make_Temporary (Loc, 'S');
       Append_To (List_Def,
         Make_Subtype_Declaration (Loc,
           Defining_Identifier => Str_Type,
@@ -3838,7 +3827,7 @@  package body Exp_Util is
       --    E : Str_Type;
       --  end Equiv_T;
 
-      Equiv_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('T'));
+      Equiv_Type := Make_Temporary (Loc, 'T');
       Set_Ekind (Equiv_Type, E_Record_Type);
       Set_Parent_Subtype (Equiv_Type, Constr_Root);
 
@@ -3863,9 +3852,7 @@  package body Exp_Util is
 
       Append_To (Comp_List,
         Make_Component_Declaration (Loc,
-          Defining_Identifier =>
-            Make_Defining_Identifier (Loc,
-              Chars => New_Internal_Name ('C')),
+          Defining_Identifier  => Make_Temporary (Loc, 'C'),
           Component_Definition =>
             Make_Component_Definition (Loc,
               Aliased_Present    => False,
@@ -3991,15 +3978,12 @@  package body Exp_Util is
          --  actual or an explicit subtype.
 
          Utyp        := Underlying_Type (Base_Type (Unc_Typ));
-         Full_Subtyp := Make_Defining_Identifier (Loc,
-                          New_Internal_Name ('C'));
+         Full_Subtyp := Make_Temporary (Loc, 'C');
          Full_Exp    :=
-           Unchecked_Convert_To
-             (Utyp, Duplicate_Subexpr_No_Checks (E));
+           Unchecked_Convert_To (Utyp, Duplicate_Subexpr_No_Checks (E));
          Set_Parent (Full_Exp, Parent (E));
 
-         Priv_Subtyp :=
-           Make_Defining_Identifier (Loc, New_Internal_Name ('P'));
+         Priv_Subtyp := Make_Temporary (Loc, 'P');
 
          Insert_Action (E,
            Make_Subtype_Declaration (Loc,
@@ -4870,7 +4854,7 @@  package body Exp_Util is
             end;
          end if;
 
-         Ref_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('A'));
+         Ref_Type := Make_Temporary (Loc, 'A');
 
          Ptr_Typ_Decl :=
            Make_Full_Type_Declaration (Loc,
Index: exp_pakd.adb
===================================================================
--- exp_pakd.adb	(revision 160834)
+++ exp_pakd.adb	(working copy)
@@ -1347,10 +1347,9 @@  package body Exp_Pakd is
          begin
             Decl :=
               Make_Object_Declaration (Loc,
-                Defining_Identifier =>
-                  Make_Defining_Identifier (Loc,  New_Internal_Name ('T')),
-                Object_Definition => New_Occurrence_Of (Ctyp, Loc),
-                Expression => New_Copy_Tree (Rhs));
+                Defining_Identifier => Make_Temporary (Loc, 'T', Rhs),
+                Object_Definition   => New_Occurrence_Of (Ctyp, Loc),
+                Expression          => New_Copy_Tree (Rhs));
 
             Insert_Actions (N, New_List (Decl));
             Rhs := New_Occurrence_Of (Defining_Identifier (Decl), Loc);
@@ -1841,11 +1840,8 @@  package body Exp_Pakd is
 
       else
          declare
-            Result_Ent : constant Entity_Id :=
-                           Make_Defining_Identifier (Loc,
-                             Chars => New_Internal_Name ('T'));
-
-            E_Id : RE_Id;
+            Result_Ent : constant Entity_Id := Make_Temporary (Loc, 'T');
+            E_Id       : RE_Id;
 
          begin
             if Nkind (N) = N_Op_And then
@@ -2192,9 +2188,7 @@  package body Exp_Pakd is
 
       else
          declare
-            Result_Ent : constant Entity_Id :=
-                           Make_Defining_Identifier (Loc,
-                             Chars => New_Internal_Name ('T'));
+            Result_Ent : constant Entity_Id := Make_Temporary (Loc, 'T');
 
          begin
             Insert_Actions (N, New_List (
Index: exp_sel.adb
===================================================================
--- exp_sel.adb	(revision 160834)
+++ exp_sel.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -83,19 +83,13 @@  package body Exp_Sel is
      (Loc   : Source_Ptr;
       Decls : List_Id) return Entity_Id
    is
-      B : constant Entity_Id := Make_Defining_Identifier (Loc,
-                                  Chars => New_Internal_Name ('B'));
-
+      B : constant Entity_Id := Make_Temporary (Loc, 'B');
    begin
       Append_To (Decls,
         Make_Object_Declaration (Loc,
-          Defining_Identifier =>
-            B,
-          Object_Definition =>
-            New_Reference_To (Standard_Boolean, Loc),
-          Expression =>
-            New_Reference_To (Standard_False, Loc)));
-
+          Defining_Identifier => B,
+          Object_Definition   => New_Reference_To (Standard_Boolean, Loc),
+          Expression          => New_Reference_To (Standard_False, Loc)));
       return B;
    end Build_B;
 
@@ -107,17 +101,12 @@  package body Exp_Sel is
      (Loc   : Source_Ptr;
       Decls : List_Id) return Entity_Id
    is
-      C : constant Entity_Id := Make_Defining_Identifier (Loc,
-                                  Chars => New_Internal_Name ('C'));
-
+      C : constant Entity_Id := Make_Temporary (Loc, 'C');
    begin
       Append_To (Decls,
         Make_Object_Declaration (Loc,
-          Defining_Identifier =>
-            C,
-          Object_Definition =>
-            New_Reference_To (RTE (RE_Prim_Op_Kind), Loc)));
-
+          Defining_Identifier => C,
+          Object_Definition => New_Reference_To (RTE (RE_Prim_Op_Kind), Loc)));
       return C;
    end Build_C;
 
@@ -155,9 +144,7 @@  package body Exp_Sel is
       Decls : List_Id;
       Obj   : Entity_Id) return Entity_Id
    is
-      K : constant Entity_Id := Make_Defining_Identifier (Loc,
-                                  Chars => New_Internal_Name ('K'));
-
+      K : constant Entity_Id := Make_Temporary (Loc, 'K');
    begin
       Append_To (Decls,
         Make_Object_Declaration (Loc,
@@ -169,7 +156,6 @@  package body Exp_Sel is
               Name => New_Reference_To (RTE (RE_Get_Tagged_Kind), Loc),
               Parameter_Associations => New_List (
                 Unchecked_Convert_To (RTE (RE_Tag), Obj)))));
-
       return K;
    end Build_K;
 
@@ -181,16 +167,12 @@  package body Exp_Sel is
      (Loc   : Source_Ptr;
       Decls : List_Id) return Entity_Id
    is
-      S : constant Entity_Id := Make_Defining_Identifier (Loc,
-                                  Chars => New_Internal_Name ('S'));
-
+      S : constant Entity_Id := Make_Temporary (Loc, 'S');
    begin
       Append_To (Decls,
         Make_Object_Declaration (Loc,
           Defining_Identifier => S,
-          Object_Definition   =>
-            New_Reference_To (Standard_Integer, Loc)));
-
+          Object_Definition   => New_Reference_To (Standard_Integer, Loc)));
       return S;
    end Build_S;
 
Index: exp_fixd.adb
===================================================================
--- exp_fixd.adb	(revision 160834)
+++ exp_fixd.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -505,8 +505,8 @@  package body Exp_Fixd is
       --  Define quotient and remainder, and set their Etypes, so
       --  that they can be picked up by Build_xxx routines.
 
-      Qnn := Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
-      Rnn := Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
+      Qnn := Make_Temporary (Loc, 'S');
+      Rnn := Make_Temporary (Loc, 'R');
 
       Set_Etype (Qnn, QR_Typ);
       Set_Etype (Rnn, QR_Typ);
@@ -518,8 +518,8 @@  package body Exp_Fixd is
          --  Create temporaries for numerator and denominator and set Etypes,
          --  so that New_Occurrence_Of picks them up for Build_xxx calls.
 
-         Nnn := Make_Defining_Identifier (Loc, New_Internal_Name ('N'));
-         Dnn := Make_Defining_Identifier (Loc, New_Internal_Name ('D'));
+         Nnn := Make_Temporary (Loc, 'N');
+         Dnn := Make_Temporary (Loc, 'D');
 
          Set_Etype (Nnn, QR_Typ);
          Set_Etype (Dnn, QR_Typ);
@@ -882,8 +882,8 @@  package body Exp_Fixd is
       --  Define quotient and remainder, and set their Etypes, so
       --  that they can be picked up by Build_xxx routines.
 
-      Qnn := Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
-      Rnn := Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
+      Qnn := Make_Temporary (Loc, 'S');
+      Rnn := Make_Temporary (Loc, 'R');
 
       Set_Etype (Qnn, QR_Typ);
       Set_Etype (Rnn, QR_Typ);
@@ -891,8 +891,8 @@  package body Exp_Fixd is
       --  Case that we can compute the numerator in 64 bits
 
       if QR_Siz <= 64 then
-         Nnn := Make_Defining_Identifier (Loc, New_Internal_Name  ('N'));
-         Dnn := Make_Defining_Identifier (Loc, New_Internal_Name  ('D'));
+         Nnn := Make_Temporary (Loc, 'N');
+         Dnn := Make_Temporary (Loc, 'D');
 
          --  Set Etypes, so that they can be picked up by New_Occurrence_Of
 
Index: exp_intr.adb
===================================================================
--- exp_intr.adb	(revision 160834)
+++ exp_intr.adb	(working copy)
@@ -171,11 +171,10 @@  package body Exp_Intr is
 
             Iface_Tag :=
               Make_Object_Declaration (Loc,
-                Defining_Identifier =>
-                  Make_Defining_Identifier (Loc, New_Internal_Name ('V')),
-                Object_Definition =>
+                Defining_Identifier => Make_Temporary (Loc, 'V'),
+                Object_Definition   =>
                   New_Reference_To (RTE (RE_Tag), Loc),
-                Expression =>
+                Expression          =>
                   Make_Function_Call (Loc,
                     Name => New_Reference_To (RTE (RE_Secondary_Tag), Loc),
                     Parameter_Associations => New_List (
@@ -325,7 +324,7 @@  package body Exp_Intr is
             --  be referencing it by normal visibility methods.
 
             if No (Choice_Parameter (P)) then
-               E := Make_Defining_Identifier (Loc, New_Internal_Name ('E'));
+               E := Make_Temporary (Loc, 'E');
                Set_Choice_Parameter (P, E);
                Set_Ekind (E, E_Variable);
                Set_Etype (E, RTE (RE_Exception_Occurrence));
@@ -362,11 +361,9 @@  package body Exp_Intr is
       Loc : constant Source_Ptr := Sloc (N);
       Ent : constant Entity_Id  := Entity (Name (N));
       Str : constant Node_Id    := First_Actual (N);
-      Dum : Entity_Id;
+      Dum : constant Entity_Id  := Make_Temporary (Loc, 'D');
 
    begin
-      Dum := Make_Defining_Identifier (Loc, New_Internal_Name ('D'));
-
       Insert_Actions (N, New_List (
         Make_Object_Declaration (Loc,
           Defining_Identifier => Dum,
@@ -1025,13 +1022,11 @@  package body Exp_Intr is
                   D_Type := Entity (D_Subtyp);
 
                else
-                  D_Type := Make_Defining_Identifier (Loc,
-                              New_Internal_Name ('A'));
+                  D_Type := Make_Temporary (Loc, 'A');
                   Insert_Action (Deref,
                     Make_Subtype_Declaration (Loc,
                       Defining_Identifier => D_Type,
                       Subtype_Indication  => D_Subtyp));
-
                end if;
 
                --  Force freezing at the point of the dereference. For the
Index: itypes.ads
===================================================================
--- itypes.ads	(revision 160834)
+++ itypes.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -127,7 +127,7 @@  package Itypes is
    --  If the implicit type does not need an external name, then the
    --  Related_Id parameter is omitted (and hence Empty). In this case
    --  Suffix and Suffix_Index are ignored and the implicit type name is
-   --  created by a call to New_Internal_Name ('T').
+   --  created by a call to Make_Temporary.
    --
    --  Note that in all cases, the name starts with "T". This is used
    --  to identify implicit types in the error message handling circuits.
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 160889)
+++ sem_ch3.adb	(working copy)
@@ -1364,7 +1364,7 @@  package body Sem_Ch3 is
              Subtype_Indication =>
                New_Occurrence_Of (RTE (RE_Interface_Tag), Loc));
 
-         Tag := Make_Defining_Identifier (Loc, New_Internal_Name ('V'));
+         Tag := Make_Temporary (Loc, 'V');
 
          Decl :=
            Make_Component_Declaration (Loc,
@@ -1406,8 +1406,7 @@  package body Sem_Ch3 is
                 Subtype_Indication =>
                   New_Occurrence_Of (RTE (RE_Storage_Offset), Loc));
 
-            Offset :=
-              Make_Defining_Identifier (Loc, New_Internal_Name ('V'));
+            Offset := Make_Temporary (Loc, 'V');
 
             Decl :=
               Make_Component_Declaration (Loc,
@@ -4323,9 +4322,7 @@  package body Sem_Ch3 is
                Decl  : Entity_Id;
 
             begin
-               New_E :=
-                 Make_Defining_Identifier (Loc,
-                   Chars => New_Internal_Name ('T'));
+               New_E := Make_Temporary (Loc, 'T');
                Set_Is_Internal (New_E);
 
                Decl :=
@@ -4574,10 +4571,7 @@  package body Sem_Ch3 is
       Curr_Scope : constant Scope_Stack_Entry :=
                      Scope_Stack.Table (Scope_Stack.Last);
 
-      Anon : constant Entity_Id :=
-               Make_Defining_Identifier (Loc,
-                 Chars => New_Internal_Name ('S'));
-
+      Anon : constant Entity_Id := Make_Temporary (Loc, 'S');
       Acc  : Node_Id;
       Comp : Node_Id;
       Decl : Node_Id;
@@ -4919,9 +4913,7 @@  package body Sem_Ch3 is
    is
       Loc : constant Source_Ptr := Sloc (N);
 
-      Corr_Record : constant Entity_Id :=
-                      Make_Defining_Identifier (Loc, New_Internal_Name ('C'));
-
+      Corr_Record      : constant Entity_Id := Make_Temporary (Loc, 'C');
       Corr_Decl        : Node_Id;
       Corr_Decl_Needed : Boolean;
       --  If the derived type has fewer discriminants than its parent, the
@@ -5724,9 +5716,7 @@  package body Sem_Ch3 is
            and then Expander_Active
          then
             declare
-               Full_Der : constant Entity_Id :=
-                            Make_Defining_Identifier (Loc,
-                              Chars => New_Internal_Name ('T'));
+               Full_Der : constant Entity_Id := Make_Temporary (Loc, 'T');
                New_Ext  : constant Node_Id :=
                             Copy_Separate_Tree
                               (Record_Extension_Part (Type_Definition (N)));
@@ -9655,14 +9645,11 @@  package body Sem_Ch3 is
          then
             declare
                Loc    : constant Source_Ptr := Sloc (N);
-               Def_Id : constant Entity_Id :=
-                          Make_Defining_Identifier (Loc,
-                            New_Internal_Name ('S'));
-               Decl   : constant Node_Id :=
+               Def_Id : constant Entity_Id  := Make_Temporary (Loc, 'S');
+               Decl   : constant Node_Id    :=
                           Make_Subtype_Declaration (Loc,
-                            Defining_Identifier =>
-                              Def_Id,
-                            Subtype_Indication =>
+                            Defining_Identifier => Def_Id,
+                            Subtype_Indication  =>
                               Relocate_Node (Curr_Obj_Def));
 
             begin
@@ -17693,9 +17680,7 @@  package body Sem_Ch3 is
                 (Access_Definition (Comp_Def));
 
             Build_Incomplete_Type_Declaration;
-            Anon_Access :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('S'));
+            Anon_Access := Make_Temporary (Loc, 'S');
 
             --  Create a declaration for the anonymous access type: either
             --  an access_to_object or an access_to_subprogram.
Index: sem_dist.adb
===================================================================
--- sem_dist.adb	(revision 160834)
+++ sem_dist.adb	(working copy)
@@ -451,9 +451,7 @@  package body Sem_Dist is
       --  True iff this RAS has an access formal parameter (see
       --  Exp_Dist.Add_RAS_Dereference_TSS for details).
 
-      Subpkg      : constant Entity_Id :=
-                      Make_Defining_Identifier (Loc,
-                        New_Internal_Name ('S'));
+      Subpkg      : constant Entity_Id := Make_Temporary (Loc, 'S');
       Subpkg_Decl : Node_Id;
       Subpkg_Body : Node_Id;
       Vis_Decls   : constant List_Id := New_List;
@@ -464,16 +462,14 @@  package body Sem_Dist is
                       New_External_Name (Chars (User_Type), 'R'));
 
       Full_Obj_Type : constant Entity_Id :=
-                        Make_Defining_Identifier (Loc,
-                          Chars (Obj_Type));
+                        Make_Defining_Identifier (Loc, Chars (Obj_Type));
 
       RACW_Type : constant Entity_Id :=
                     Make_Defining_Identifier (Loc,
                       New_External_Name (Chars (User_Type), 'P'));
 
       Fat_Type : constant Entity_Id :=
-                   Make_Defining_Identifier (Loc,
-                     Chars (User_Type));
+                   Make_Defining_Identifier (Loc, Chars (User_Type));
 
       Fat_Type_Decl : Node_Id;
 
Index: sem_ch5.adb
===================================================================
--- sem_ch5.adb	(revision 160889)
+++ sem_ch5.adb	(working copy)
@@ -1520,9 +1520,7 @@  package body Sem_Ch5 is
 
             Analyze_And_Resolve (Original_Bound, Typ);
 
-            Id :=
-              Make_Defining_Identifier (Loc,
-                Chars => New_Internal_Name ('S'));
+            Id := Make_Temporary (Loc, 'S', Original_Bound);
 
             --  Normally, the best approach is simply to generate a constant
             --  declaration that captures the bound. However, there is a nasty
@@ -1721,13 +1719,10 @@  package body Sem_Ch5 is
          then
             declare
                Loc  : constant Source_Ptr := Sloc (N);
-               Arr  : constant Entity_Id :=
-                        Etype (Entity (Prefix (DS)));
+               Arr  : constant Entity_Id := Etype (Entity (Prefix (DS)));
                Indx : constant Entity_Id :=
                         Base_Type (Etype (First_Index (Arr)));
-               Subt : constant Entity_Id :=
-                        Make_Defining_Identifier
-                          (Loc, New_Internal_Name ('S'));
+               Subt : constant Entity_Id := Make_Temporary (Loc, 'S');
                Decl : Node_Id;
 
             begin
Index: sem_ch9.adb
===================================================================
--- sem_ch9.adb	(revision 160889)
+++ sem_ch9.adb	(working copy)
@@ -991,9 +991,7 @@  package body Sem_Ch9 is
    procedure Analyze_Entry_Index_Specification (N : Node_Id) is
       Iden    : constant Node_Id   := Defining_Identifier (N);
       Def     : constant Node_Id   := Discrete_Subtype_Definition (N);
-      Loop_Id : constant Entity_Id :=
-                  Make_Defining_Identifier (Sloc (N),
-                    Chars => New_Internal_Name ('L'));
+      Loop_Id : constant Entity_Id := Make_Temporary (Sloc (N), 'L');
 
    begin
       Tasking_Used := True;
Index: sem_ch10.adb
===================================================================
--- sem_ch10.adb	(revision 160889)
+++ sem_ch10.adb	(working copy)
@@ -5346,7 +5346,7 @@  package body Sem_Ch10 is
          --  and the full-view.
 
          if No (Class_Wide_Type (T)) then
-            CW := Make_Defining_Identifier (Loc,  New_Internal_Name ('S'));
+            CW := Make_Temporary (Loc, 'S');
 
             --  Set parent to be the same as the parent of the tagged type.
             --  We need a parent field set, and it is supposed to point to
@@ -5398,9 +5398,7 @@  package body Sem_Ch10 is
          Sloc_Value : Source_Ptr;
          Id_Char    : Character) return Entity_Id
       is
-         E : constant Entity_Id :=
-               Make_Defining_Identifier (Sloc_Value,
-                 Chars => New_Internal_Name (Id_Char));
+         E : constant Entity_Id := Make_Temporary (Sloc_Value, Id_Char);
 
       begin
          Set_Ekind       (E, Kind);
@@ -5475,9 +5473,7 @@  package body Sem_Ch10 is
 
       --  Build the header of the limited_view
 
-      Lim_Header :=
-        Make_Defining_Identifier (Sloc (N),
-          Chars => New_Internal_Name (Id_Char => 'Z'));
+      Lim_Header := Make_Temporary (Sloc (N), 'Z');
       Set_Ekind (Lim_Header, E_Package);
       Set_Is_Internal (Lim_Header);
       Set_Limited_View (P, Lim_Header);
Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb	(revision 160889)
+++ sem_ch12.adb	(working copy)
@@ -7865,8 +7865,7 @@  package body Sem_Ch12 is
          if not Box_Present (Formal) then
             declare
                I_Pack : constant Entity_Id :=
-                          Make_Defining_Identifier (Sloc (Actual),
-                            Chars => New_Internal_Name  ('P'));
+                          Make_Temporary (Sloc (Actual), 'P');
 
             begin
                Set_Is_Internal (I_Pack);
@@ -8165,9 +8164,8 @@  package body Sem_Ch12 is
          --  to prevent freezing anomalies.
 
          declare
-            Anon_Id : constant Entity_Id :=
-                        Make_Defining_Identifier
-                          (Loc, New_Internal_Name ('E'));
+            Anon_Id : constant Entity_Id := Make_Temporary (Loc, 'E');
+
          begin
             Set_Defining_Unit_Name (New_Spec, Anon_Id);
             Insert_Before (Instantiation_Node, Decl_Node);
@@ -8314,8 +8312,7 @@  package body Sem_Ch12 is
 
             Subt_Decl :=
               Make_Subtype_Declaration (Loc,
-                 Defining_Identifier =>
-                   Make_Defining_Identifier (Loc, New_Internal_Name ('P')),
+                 Defining_Identifier => Make_Temporary (Loc, 'P'),
                  Subtype_Indication  => New_Occurrence_Of (Ftyp, Loc));
 
             Prepend (Subt_Decl, List);
@@ -10340,8 +10337,7 @@  package body Sem_Ch12 is
             Corr_Decl : Node_Id;
 
          begin
-            New_Corr := Make_Defining_Identifier (Loc,
-                            Chars => New_Internal_Name  ('S'));
+            New_Corr := Make_Temporary (Loc, 'S');
             Corr_Decl :=
               Make_Subtype_Declaration (Loc,
                 Defining_Identifier => New_Corr,
Index: tbuild.ads
===================================================================
--- tbuild.ads	(revision 160894)
+++ tbuild.ads	(working copy)
@@ -277,6 +277,9 @@  package Tbuild is
    --  if the identical unit is compiled with a semantically consistent set
    --  of sources, the numbers will be consistent. This means that it is fine
    --  to use these as public symbols.
+   --
+   --  Note: Nearly all uses of this function are via calls to Make_Temporary,
+   --  but there are just a few cases where it is called directly.
 
    function New_Occurrence_Of
      (Def_Id : Entity_Id;
Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 160892)
+++ sem_util.adb	(working copy)
@@ -398,9 +398,7 @@  package body Sem_Util is
          end loop;
       end if;
 
-      Subt :=
-        Make_Defining_Identifier (Loc,
-          Chars => New_Internal_Name ('S'));
+      Subt := Make_Temporary (Loc, 'S');
       Set_Is_Internal (Subt);
 
       Decl :=
@@ -624,9 +622,7 @@  package body Sem_Util is
          return Empty;
       end if;
 
-      Subt :=
-        Make_Defining_Identifier (Loc,
-          Chars => New_Internal_Name ('S'));
+      Subt := Make_Temporary (Loc, 'S');
       Set_Is_Internal (Subt);
 
       Decl :=
@@ -666,10 +662,7 @@  package body Sem_Util is
       end if;
 
       declare
-         Act : constant Entity_Id :=
-                 Make_Defining_Identifier (Loc,
-                   Chars => New_Internal_Name ('S'));
-
+         Act         : constant Entity_Id := Make_Temporary (Loc, 'S');
          Constraints : constant List_Id := New_List;
          Decl        : Node_Id;
 
@@ -2080,9 +2073,7 @@  package body Sem_Util is
                --  so we can continue semantic analysis
 
                elsif Nam = Error then
-                  Err :=
-                    Make_Defining_Identifier (Sloc (N),
-                      Chars => New_Internal_Name ('T'));
+                  Err := Make_Temporary (Sloc (N), 'T');
                   Set_Defining_Unit_Name (N, Err);
 
                   return Err;
@@ -8851,8 +8842,7 @@  package body Sem_Util is
       Sloc_Value : Source_Ptr;
       Id_Char    : Character) return Entity_Id
    is
-      N : constant Entity_Id :=
-            Make_Defining_Identifier (Sloc_Value, New_Internal_Name (Id_Char));
+      N : constant Entity_Id := Make_Temporary (Sloc_Value, Id_Char);
 
    begin
       Set_Ekind          (N, Kind);
Index: sem_ch4.adb
===================================================================
--- sem_ch4.adb	(revision 160889)
+++ sem_ch4.adb	(working copy)
@@ -472,8 +472,7 @@  package body Sem_Ch4 is
                end if;
 
                if Expander_Active then
-                  Def_Id :=
-                    Make_Defining_Identifier (Loc, New_Internal_Name ('S'));
+                  Def_Id := Make_Temporary (Loc, 'S');
 
                   Insert_Action (E,
                     Make_Subtype_Declaration (Loc,
Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb	(revision 160891)
+++ sem_ch8.adb	(working copy)
@@ -910,9 +910,7 @@  package body Sem_Ch8 is
                then
                   declare
                      Loc  : constant Source_Ptr := Sloc (N);
-                     Subt : constant Entity_Id :=
-                              Make_Defining_Identifier (Loc,
-                                Chars => New_Internal_Name ('T'));
+                     Subt : constant Entity_Id  := Make_Temporary (Loc, 'T');
                   begin
                      Remove_Side_Effects (Nam);
                      Insert_Action (N,
@@ -2837,19 +2835,17 @@  package body Sem_Ch8 is
 
       if Aname = Name_AST_Entry then
          declare
-            Ent  : Entity_Id;
+            Ent  : constant Entity_Id := Make_Temporary (Loc, 'R', Nam);
             Decl : Node_Id;
 
          begin
-            Ent := Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
-
             Decl :=
               Make_Object_Declaration (Loc,
                 Defining_Identifier => Ent,
-                Object_Definition =>
+                Object_Definition   =>
                   New_Occurrence_Of (RTE (RE_AST_Handler), Loc),
-                Expression => Nam,
-                Constant_Present => True);
+                Expression          => Nam,
+                Constant_Present    => True);
 
             Set_Assignment_OK (Decl, True);
             Insert_Action (N, Decl);
Index: sem_ch13.adb
===================================================================
--- sem_ch13.adb	(revision 160892)
+++ sem_ch13.adb	(working copy)
@@ -1742,9 +1742,7 @@  package body Sem_Ch13 is
             if not Is_Entity_Name (Expr)
               and then Is_Object_Reference (Expr)
             then
-               Pool :=
-                 Make_Defining_Identifier (Loc,
-                   Chars => New_Internal_Name ('P'));
+               Pool := Make_Temporary (Loc, 'P', Expr);
 
                declare
                   Rnode : constant Node_Id :=
@@ -1752,7 +1750,7 @@  package body Sem_Ch13 is
                               Defining_Identifier => Pool,
                               Subtype_Mark        =>
                                 New_Occurrence_Of (Etype (Expr), Loc),
-                              Name => Expr);
+                              Name                => Expr);
 
                begin
                   Insert_Before (N, Rnode);
Index: exp_ch9.adb
===================================================================
--- exp_ch9.adb	(revision 160895)
+++ exp_ch9.adb	(working copy)
@@ -2132,7 +2132,6 @@  package body Exp_Ch9 is
          --  record type, so mark the spec accordingly.
 
          if Ekind (Subp_Id) = E_Function then
-
             declare
                Res_Def : Node_Id;
 
@@ -2388,12 +2387,10 @@  package body Exp_Ch9 is
          Add_Object_Pointer (Loc, Typ, Decls);
 
          while Present (Ent) loop
-
             if Ekind (Ent) = E_Entry then
                Add_If_Clause (Make_Integer_Literal (Loc, 1));
 
             elsif Ekind (Ent) = E_Entry_Family then
-
                E_Typ := Etype (Discrete_Subtype_Definition (Parent (Ent)));
                Hi := Convert_Discriminant_Ref (Type_High_Bound (E_Typ));
                Lo := Convert_Discriminant_Ref (Type_Low_Bound  (E_Typ));
Index: exp_dist.adb
===================================================================
--- exp_dist.adb	(revision 160895)
+++ exp_dist.adb	(working copy)
@@ -9358,7 +9358,7 @@  package body Exp_Dist is
             --  that the expected type of its parameter is U_Type.
 
             if Ekind (Fnam) = E_Function
-                 and then Present (First_Formal (Fnam))
+              and then Present (First_Formal (Fnam))
             then
                C_Type := Etype (First_Formal (Fnam));
             else