* [Ada] Crash freezing declaration that will raise constraint error
@ 2022-05-17 8:27 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-17 8:27 UTC (permalink / raw)
To: gcc-patches; +Cc: Javier Miranda
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
When the compiler is built with assertions enabled and processes the
following declarations:
type Vector_Boolean_Array is array (1 .. 10) of Boolean;
O2 : constant Vector_Boolean_Array := [for J in 2 => True];
The expression is rewritten by the frontend with an N_Raise_CE node,
which leads to an assertion error at the freezing point of the object
declaration.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* freeze.adb (Freeze_Entity): Protect the call to
Declaration_Node against entities of expressions replaced by the
frontend with an N_Raise_CE node.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 803 bytes --]
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -6582,9 +6582,13 @@ package body Freeze is
end if;
end if;
- -- Special processing for objects created by object declaration
+ -- Special processing for objects created by object declaration;
+ -- we protect the call to Declaration_Node against entities of
+ -- expressions replaced by the frontend with an N_Raise_CE node.
- if Nkind (Declaration_Node (E)) = N_Object_Declaration then
+ if Ekind (E) in E_Constant | E_Variable
+ and then Nkind (Declaration_Node (E)) = N_Object_Declaration
+ then
Freeze_Object_Declaration (E);
end if;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-17 8:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 8:27 [Ada] Crash freezing declaration that will raise constraint error Pierre-Marie de Rodat
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).