* [COMMITTED] ada: Crash processing pragmas Compile_Time_Error and Compile_Time_Warning
@ 2023-10-10 12:14 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-10-10 12:14 UTC (permalink / raw)
To: gcc-patches; +Cc: Javier Miranda
From: Javier Miranda <miranda@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_attr.adb | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index d03761b1e30..3eba3a29362 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;
--
2.42.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-10 12:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-10 12:14 [COMMITTED] ada: Crash processing pragmas Compile_Time_Error and Compile_Time_Warning Marc Poulhiès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).