[Ada] Internal cleanups in Cstand

Arnaud Charlet charlet@adacore.com
Wed Jul 30 14:32:00 GMT 2014


The name of raise type was "any type", it is now "raise type"

We now the name before setting other fields of standard entities,
which avoids debugger blowups printing the entity when setting
one of these fields.

These are minor internal imrpovements for front-end debugging,
no external effect, no test required.

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

2014-07-30  Robert Dewar  <dewar@adacore.com>

	* cstand.adb (New_Standard_Entity): New version takes name
	string to call Make_Name.
	(Create_Standard): Use this routine to set name before setting other
	fields.

-------------- next part --------------
Index: cstand.adb
===================================================================
--- cstand.adb	(revision 213263)
+++ cstand.adb	(working copy)
@@ -151,6 +151,10 @@
      (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id;
    --  Builds a new entity for Standard
 
+   function New_Standard_Entity (S : String) return Entity_Id;
+   --  Builds a new entity for Standard with Nkind = N_Defining_Identifier,
+   --  and Chars of this defining identifier set to the given string S.
+
    procedure Print_Standard;
    --  Print representation of package Standard if switch set
 
@@ -1204,30 +1208,27 @@
       --  filled out to minimize problems with cascaded errors (for example,
       --  Any_Integer is given reasonable and consistent type and size values)
 
-      Any_Type := New_Standard_Entity;
+      Any_Type := New_Standard_Entity ("any type");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Any_Type);
       Set_Scope (Any_Type, Standard_Standard);
       Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
-      Make_Name (Any_Type, "any type");
 
-      Any_Id := New_Standard_Entity;
+      Any_Id := New_Standard_Entity ("any id");
       Set_Ekind             (Any_Id, E_Variable);
       Set_Scope             (Any_Id, Standard_Standard);
       Set_Etype             (Any_Id, Any_Type);
       Init_Esize            (Any_Id);
       Init_Alignment        (Any_Id);
-      Make_Name             (Any_Id, "any id");
 
-      Any_Access := New_Standard_Entity;
+      Any_Access := New_Standard_Entity ("an access type");
       Set_Ekind             (Any_Access, E_Access_Type);
       Set_Scope             (Any_Access, Standard_Standard);
       Set_Etype             (Any_Access, Any_Access);
       Init_Size             (Any_Access, System_Address_Size);
       Set_Elem_Alignment    (Any_Access);
-      Make_Name             (Any_Access, "an access type");
 
-      Any_Character := New_Standard_Entity;
+      Any_Character := New_Standard_Entity ("a character type");
       Set_Ekind             (Any_Character, E_Enumeration_Type);
       Set_Scope             (Any_Character, Standard_Standard);
       Set_Etype             (Any_Character, Any_Character);
@@ -1237,18 +1238,16 @@
       Init_RM_Size          (Any_Character, 8);
       Set_Elem_Alignment    (Any_Character);
       Set_Scalar_Range      (Any_Character, Scalar_Range (Standard_Character));
-      Make_Name             (Any_Character, "a character type");
 
-      Any_Array := New_Standard_Entity;
+      Any_Array := New_Standard_Entity ("an array type");
       Set_Ekind             (Any_Array, E_Array_Type);
       Set_Scope             (Any_Array, Standard_Standard);
       Set_Etype             (Any_Array, Any_Array);
       Set_Component_Type    (Any_Array, Any_Character);
       Init_Size_Align       (Any_Array);
-      Make_Name             (Any_Array, "an array type");
       Make_Dummy_Index      (Any_Array);
 
-      Any_Boolean := New_Standard_Entity;
+      Any_Boolean := New_Standard_Entity ("a boolean type");
       Set_Ekind             (Any_Boolean, E_Enumeration_Type);
       Set_Scope             (Any_Boolean, Standard_Standard);
       Set_Etype             (Any_Boolean, Standard_Boolean);
@@ -1257,34 +1256,30 @@
       Set_Elem_Alignment    (Any_Boolean);
       Set_Is_Unsigned_Type  (Any_Boolean);
       Set_Scalar_Range      (Any_Boolean, Scalar_Range (Standard_Boolean));
-      Make_Name             (Any_Boolean, "a boolean type");
 
-      Any_Composite := New_Standard_Entity;
+      Any_Composite := New_Standard_Entity ("a composite type");
       Set_Ekind             (Any_Composite, E_Array_Type);
       Set_Scope             (Any_Composite, Standard_Standard);
       Set_Etype             (Any_Composite, Any_Composite);
       Set_Component_Size    (Any_Composite, Uint_0);
       Set_Component_Type    (Any_Composite, Standard_Integer);
       Init_Size_Align       (Any_Composite);
-      Make_Name             (Any_Composite, "a composite type");
 
-      Any_Discrete := New_Standard_Entity;
+      Any_Discrete := New_Standard_Entity ("a discrete type");
       Set_Ekind             (Any_Discrete, E_Signed_Integer_Type);
       Set_Scope             (Any_Discrete, Standard_Standard);
       Set_Etype             (Any_Discrete, Any_Discrete);
       Init_Size             (Any_Discrete, Standard_Integer_Size);
       Set_Elem_Alignment    (Any_Discrete);
-      Make_Name             (Any_Discrete, "a discrete type");
 
-      Any_Fixed := New_Standard_Entity;
+      Any_Fixed := New_Standard_Entity ("a fixed-point type");
       Set_Ekind             (Any_Fixed, E_Ordinary_Fixed_Point_Type);
       Set_Scope             (Any_Fixed, Standard_Standard);
       Set_Etype             (Any_Fixed, Any_Fixed);
       Init_Size             (Any_Fixed, Standard_Integer_Size);
       Set_Elem_Alignment    (Any_Fixed);
-      Make_Name             (Any_Fixed, "a fixed-point type");
 
-      Any_Integer := New_Standard_Entity;
+      Any_Integer := New_Standard_Entity ("an integer type");
       Set_Ekind             (Any_Integer, E_Signed_Integer_Type);
       Set_Scope             (Any_Integer, Standard_Standard);
       Set_Etype             (Any_Integer, Standard_Long_Long_Integer);
@@ -1296,83 +1291,72 @@
          Typ => Base_Type (Standard_Integer),
          Lb  => Uint_0,
          Hb  => Intval (High_Bound (Scalar_Range (Standard_Integer))));
-      Make_Name (Any_Integer, "an integer type");
 
-      Any_Modular := New_Standard_Entity;
+      Any_Modular := New_Standard_Entity ("a modular type");
       Set_Ekind             (Any_Modular, E_Modular_Integer_Type);
       Set_Scope             (Any_Modular, Standard_Standard);
       Set_Etype             (Any_Modular, Standard_Long_Long_Integer);
       Init_Size             (Any_Modular, Standard_Long_Long_Integer_Size);
       Set_Elem_Alignment    (Any_Modular);
       Set_Is_Unsigned_Type  (Any_Modular);
-      Make_Name             (Any_Modular, "a modular type");
 
-      Any_Numeric := New_Standard_Entity;
+      Any_Numeric := New_Standard_Entity ("a numeric type");
       Set_Ekind             (Any_Numeric, E_Signed_Integer_Type);
       Set_Scope             (Any_Numeric, Standard_Standard);
       Set_Etype             (Any_Numeric, Standard_Long_Long_Integer);
       Init_Size             (Any_Numeric, Standard_Long_Long_Integer_Size);
       Set_Elem_Alignment    (Any_Numeric);
-      Make_Name             (Any_Numeric, "a numeric type");
 
-      Any_Real := New_Standard_Entity;
+      Any_Real := New_Standard_Entity ("a real type");
       Set_Ekind             (Any_Real, E_Floating_Point_Type);
       Set_Scope             (Any_Real, Standard_Standard);
       Set_Etype             (Any_Real, Standard_Long_Long_Float);
       Init_Size             (Any_Real,
         UI_To_Int (Esize (Standard_Long_Long_Float)));
       Set_Elem_Alignment    (Any_Real);
-      Make_Name             (Any_Real, "a real type");
 
-      Any_Scalar := New_Standard_Entity;
+      Any_Scalar := New_Standard_Entity ("a scalar type");
       Set_Ekind             (Any_Scalar, E_Signed_Integer_Type);
       Set_Scope             (Any_Scalar, Standard_Standard);
       Set_Etype             (Any_Scalar, Any_Scalar);
       Init_Size             (Any_Scalar, Standard_Integer_Size);
       Set_Elem_Alignment    (Any_Scalar);
-      Make_Name             (Any_Scalar, "a scalar type");
 
-      Any_String := New_Standard_Entity;
+      Any_String := New_Standard_Entity ("a string type");
       Set_Ekind             (Any_String, E_Array_Type);
       Set_Scope             (Any_String, Standard_Standard);
       Set_Etype             (Any_String, Any_String);
       Set_Component_Type    (Any_String, Any_Character);
       Init_Size_Align       (Any_String);
-      Make_Name             (Any_String, "a string type");
       Make_Dummy_Index      (Any_String);
 
-      Raise_Type := New_Standard_Entity;
+      Raise_Type := New_Standard_Entity ("raise type");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Raise_Type);
       Set_Scope (Raise_Type, Standard_Standard);
       Build_Signed_Integer_Type (Raise_Type, Standard_Integer_Size);
-      Make_Name (Raise_Type, "any type");
 
-      Standard_Integer_8 := New_Standard_Entity;
+      Standard_Integer_8 := New_Standard_Entity ("integer_8");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Standard_Integer_8);
-      Make_Name (Standard_Integer_8, "integer_8");
       Set_Scope (Standard_Integer_8, Standard_Standard);
       Build_Signed_Integer_Type (Standard_Integer_8, 8);
 
-      Standard_Integer_16 := New_Standard_Entity;
+      Standard_Integer_16 := New_Standard_Entity ("integer_16");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Standard_Integer_16);
-      Make_Name (Standard_Integer_16, "integer_16");
       Set_Scope (Standard_Integer_16, Standard_Standard);
       Build_Signed_Integer_Type (Standard_Integer_16, 16);
 
-      Standard_Integer_32 := New_Standard_Entity;
+      Standard_Integer_32 := New_Standard_Entity ("integer_32");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Standard_Integer_32);
-      Make_Name (Standard_Integer_32, "integer_32");
       Set_Scope (Standard_Integer_32, Standard_Standard);
       Build_Signed_Integer_Type (Standard_Integer_32, 32);
 
-      Standard_Integer_64 := New_Standard_Entity;
+      Standard_Integer_64 := New_Standard_Entity ("integer_64");
       Decl := New_Node (N_Full_Type_Declaration, Stloc);
       Set_Defining_Identifier (Decl, Standard_Integer_64);
-      Make_Name (Standard_Integer_64, "integer_64");
       Set_Scope (Standard_Integer_64, Standard_Standard);
       Build_Signed_Integer_Type (Standard_Integer_64, 64);
 
@@ -1879,6 +1863,13 @@
       return E;
    end New_Standard_Entity;
 
+   function New_Standard_Entity (S : String) return Entity_Id is
+      Ent : constant Entity_Id := New_Standard_Entity;
+   begin
+      Make_Name (Ent, S);
+      return Ent;
+   end New_Standard_Entity;
+
    --------------------
    -- Print_Standard --
    --------------------


More information about the Gcc-patches mailing list