[COMMITTED,25/30] ada: Add Is_Base_Type predicate to C interface

Message ID 20240520074858.222435-25-poulhies@adacore.com
State Committed
Commit aecb63d075838e17673e1b13f21a414d23fcf2cd
Series [COMMITTED,01/30] ada: Rework and augment documentation on strict aliasing |

Commit Message

Marc Poulhiès May 20, 2024, 7:48 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

This also documents what the predicate effectively does.


	* einfo-utils.ads (Is_Base_Type): Move to Miscellaneous Subprograms
	section and add description.
	* fe.h (Is_Base_Type): Declare.

Tested on x86_64-pc-linux-gnu, committed on master.

 gcc/ada/einfo-utils.ads | 8 ++++++--
 gcc/ada/fe.h            | 4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads
index d87a3e34f49..01953c35bc3 100644
--- a/gcc/ada/einfo-utils.ads
+++ b/gcc/ada/einfo-utils.ads
@@ -183,8 +183,6 @@  package Einfo.Utils is
    function Has_Null_Abstract_State (Id : E) return B;
    function Has_Null_Visible_Refinement (Id : E) return B;
    function Implementation_Base_Type (Id : E) return E;
-   function Is_Base_Type (Id : E) return B with Inline;
-   --  Note that Is_Base_Type returns True for nontypes
    function Is_Boolean_Type (Id : E) return B with Inline;
    function Is_Constant_Object (Id : E) return B with Inline;
    function Is_Controlled (Id : E) return B with Inline;
@@ -504,6 +502,12 @@  package Einfo.Utils is
    --  is the name of a class_wide type whose root is incomplete, return the
    --  corresponding full declaration, else return T itself.
+   function Is_Base_Type (Id : E) return B with Inline;
+   --  Return True for a type entity and False for a subtype entity. Note that
+   --  this returns True for nontypes.
+   --  WARNING: There is a matching C declaration of this subprogram in fe.h
    function Is_Entity_Name (N : Node_Id) return Boolean with Inline;
    --  Test if the node N is the name of an entity (i.e. is an identifier,
    --  expanded name, or an attribute reference that returns an entity).
diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h
index 692c29a70af..b4c1aea5c8b 100644
--- a/gcc/ada/fe.h
+++ b/gcc/ada/fe.h
@@ -98,9 +98,11 @@  extern void Set_Normalized_First_Bit	(Entity_Id, Uint);
 extern void Set_Normalized_Position	(Entity_Id, Uint);
 extern void Set_RM_Size			(Entity_Id, Uint);
+#define Is_Base_Type		einfo__utils__is_base_type
 #define Is_Entity_Name		einfo__utils__is_entity_name
-extern Boolean Is_Entity_Name		(Node_Id);
+extern Boolean Is_Base_Type	(Entity_Id);
+extern Boolean Is_Entity_Name	(Node_Id);
 #define Get_Attribute_Definition_Clause	einfo__utils__get_attribute_definition_clause