[Ada] Allow Known_Static_Component_Size (etc) on private types

Message ID 20210615102052.GA3543@adacore.com
State New
Headers show
Series
  • [Ada] Allow Known_Static_Component_Size (etc) on private types
Related show

Commit Message

Pierre-Marie de Rodat June 15, 2021, 10:20 a.m.
Use Implementation_Base_Type instead of Base_Type in certain synthesized
attributes so they work on private types.

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

gcc/ada/

	* einfo-utils.adb (Known_Component_Size,
	Known_Static_Component_Size, Unknown_Component_Size): Use
	Implementation_Base_Type instead of Base_Type.

Patch

diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -515,8 +515,8 @@  package body Einfo.Utils is
 
    function Known_Component_Size                  (E : Entity_Id) return B is
    begin
-      return Component_Size (Base_Type (E)) /= Uint_0
-        and then Component_Size (Base_Type (E)) /= No_Uint;
+      return Component_Size (Implementation_Base_Type (E)) /= Uint_0
+        and then Component_Size (Implementation_Base_Type (E)) /= No_Uint;
    end Known_Component_Size;
 
    function Known_Esize                           (E : Entity_Id) return B is
@@ -556,7 +556,7 @@  package body Einfo.Utils is
 
    function Known_Static_Component_Size           (E : Entity_Id) return B is
    begin
-      return Component_Size (Base_Type (E)) > Uint_0;
+      return Component_Size (Implementation_Base_Type (E)) > Uint_0;
    end Known_Static_Component_Size;
 
    function Known_Static_Esize                    (E : Entity_Id) return B is
@@ -604,9 +604,9 @@  package body Einfo.Utils is
 
    function Unknown_Component_Size                (E : Entity_Id) return B is
    begin
-      return Component_Size (Base_Type (E)) = Uint_0
+      return Component_Size (Implementation_Base_Type (E)) = Uint_0
                or else
-             Component_Size (Base_Type (E)) = No_Uint;
+             Component_Size (Implementation_Base_Type (E)) = No_Uint;
    end Unknown_Component_Size;
 
    function Unknown_Esize                         (E : Entity_Id) return B is