[COMMITTED,07/13] ada: Bug box for expression function with list comprehension

Message ID 20240702132130.523603-7-poulhies@adacore.com
State Committed
Commit d33104429a6662f33e05b9fcae65c87a87005749
Headers
Series [COMMITTED,01/13] ada: Document that -gnatdJ is unused |

Commit Message

Marc Poulhiès July 2, 2024, 1:21 p.m. UTC
  From: Bob Duff <duff@adacore.com>

GNAT crashes on an iterator with a filter inside an expression function
that is the completion of an earlier spec.

gcc/ada/

	* freeze.adb (Freeze_Type_Refs): If Node is in N_Has_Etype,
	check that it has had its Etype set, because this can be
	called early for expression functions that are completions.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/freeze.adb | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 757c16e6839..7cf7e847677 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -9137,6 +9137,7 @@  package body Freeze is
          --  that type is not attached to an entity in the construct.
 
          elsif Nkind (Node) in N_Has_Etype
+           and then Present (Etype (Node))
            and then Nkind (Parent (Node)) = N_Iterator_Specification
            and then Node = Name (Parent (Node))
          then