diff mbox series

[Ada] Skip types in error for test to compute array size

Message ID 20210708135012.GA2465677@adacore.com
State New
Headers show
Series [Ada] Skip types in error for test to compute array size | expand

Commit Message

Pierre-Marie de Rodat July 8, 2021, 1:50 p.m. UTC
After a syntax error, if the code is compiled with -gnatq, semantic
analysis should still proceed without internal errors if possible. Add
special case to recognize ill-formed array type.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* layout.adb (Layout_Type): Do not call Number_Dimensions if the
	type does not have First_Index set.
diff mbox series

Patch

diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -498,6 +498,7 @@  package body Layout is
          --  in GNAT, i.e. when Packed_Array_Impl_Type is set.
 
          if Is_Array_Type (E)
+           and then Present (First_Index (E))  --  Skip types in error
            and then Number_Dimensions (E) = 1
            and then not Present (Packed_Array_Impl_Type (E))
            and then Has_Pragma_Pack (E)