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 --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)