public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-226] [Ada] Failure compiling "for ... of" loop over a slice
@ 2022-05-10 8:20 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-10 8:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a445a8692c43d14c494e1edf505ee4f33cb98bb6
commit r13-226-ga445a8692c43d14c494e1edf505ee4f33cb98bb6
Author: Steve Baird <baird@adacore.com>
Date: Fri Jan 14 14:10:25 2022 -0800
[Ada] Failure compiling "for ... of" loop over a slice
In some cases involving a "for ... of" loop (not to be confused with the
more common "for ... in" loop) iterating over a slice, compilation would
fail with an internal compiler error.
gcc/ada/
* sem_util.adb (Get_Actual_Subtype): If a new subtype is built,
do not freeze it if Expander_Active is False. The idea here is
to avoid generating an unwanted Freeze_Node for a subtype that
has been conjured up solely for purposes of preanalysis.
Diff:
---
gcc/ada/sem_util.adb | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index d76b5d93511..c58b63db924 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -10724,14 +10724,24 @@ package body Sem_Util is
Set_Is_Itype (Atyp);
Analyze (Decl, Suppress => All_Checks);
Set_Associated_Node_For_Itype (Atyp, N);
- Set_Has_Delayed_Freeze (Atyp, False);
-
- -- We need to freeze the actual subtype immediately. This is
- -- needed, because otherwise this Itype will not get frozen
- -- at all, and it is always safe to freeze on creation because
- -- any associated types must be frozen at this point.
-
- Freeze_Itype (Atyp, N);
+ if Expander_Active then
+ Set_Has_Delayed_Freeze (Atyp, False);
+
+ -- We need to freeze the actual subtype immediately. This is
+ -- needed because otherwise this Itype will not get frozen
+ -- at all; it is always safe to freeze on creation because
+ -- any associated types must be frozen at this point.
+
+ -- On the other hand, if we are performing preanalysis on
+ -- a conjured-up copy of a name (see calls to
+ -- Preanalyze_Range in sem_ch5.adb) then we don't want
+ -- to freeze Atyp, now or ever. In this case, the tree
+ -- we eventually pass to the back end should contain no
+ -- references to Atyp (and a freeze node would contain
+ -- such a reference). That's why Expander_Active is tested.
+
+ Freeze_Itype (Atyp, N);
+ end if;
return Atyp;
-- Otherwise we did not build a declaration, so return original
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-10 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 8:20 [gcc r13-226] [Ada] Failure compiling "for ... of" loop over a slice 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).