aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2023-09-19 13:54:28 +0000
committerMarc Poulhiès <poulhies@adacore.com>2023-10-10 14:12:28 +0200
commit85a0ce9086f92ad406bc7093a4a652929bbeb83d (patch)
treebc4f957b5e146a7928bbf7762a5f9712f9b3b546 /gcc/ada
parenta704603d458b1e55b561ddfb4e513581ee863ed6 (diff)
downloadgcc-85a0ce9086f92ad406bc7093a4a652929bbeb83d.zip
gcc-85a0ce9086f92ad406bc7093a4a652929bbeb83d.tar.gz
gcc-85a0ce9086f92ad406bc7093a4a652929bbeb83d.tar.bz2
ada: Crash processing pragmas Compile_Time_Error and Compile_Time_Warning
gcc/ada/ * sem_attr.adb (Analyze_Attribute): Protect the frontend against replacing 'Size by its static value if 'Size is not known at compile time and we are processing pragmas Compile_Time_Warning or Compile_Time_Errors.
Diffstat (limited to 'gcc/ada')
-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;