aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r--gcc/ada/sem_attr.adb25
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index d03761b..3eba3a2 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6457,17 +6457,30 @@ package body Sem_Attr is
or else Size_Known_At_Compile_Time (Entity (P)))
then
declare
- Siz : Uint;
+ Prefix_E : Entity_Id := Entity (P);
+ Siz : Uint;
begin
- if Known_Static_RM_Size (Entity (P)) then
- Siz := RM_Size (Entity (P));
+ -- Handle private and incomplete types
+
+ if Present (Underlying_Type (Prefix_E)) then
+ Prefix_E := Underlying_Type (Prefix_E);
+ end if;
+
+ if Known_Static_RM_Size (Prefix_E) then
+ Siz := RM_Size (Prefix_E);
else
- Siz := Esize (Entity (P));
+ Siz := Esize (Prefix_E);
end if;
- Rewrite (N, Make_Integer_Literal (Sloc (N), Siz));
- Analyze (N);
+ -- Protect the frontend against cases where the attribute
+ -- Size_Known_At_Compile_Time is set, but the Esize value
+ -- is not available (see Einfo.ads).
+
+ if Present (Siz) then
+ Rewrite (N, Make_Integer_Literal (Sloc (N), Siz));
+ Analyze (N);
+ end if;
end;
end if;