[Ada] Fix on computation of packed array size in case of error

gcc/ada/

	* layout.adb (Layout_Type): Add guard before calling Expr_Value.
This commit is contained in:
Yannick Moy 2021-05-26 10:49:14 +02:00 committed by Pierre-Marie de Rodat
parent 36fcfed88c
commit 242c0f4772
1 changed files with 19 additions and 9 deletions

View File

@ -513,11 +513,20 @@ package body Layout is
begin
Get_Index_Bounds (First_Index (E), Lo, Hi);
-- Even if the bounds are known at compile time, they could
-- have been replaced by an error node. Check each bound
-- explicitly.
if Compile_Time_Known_Value (Lo)
and then Compile_Time_Known_Value (Hi)
then
Siz := (Expr_Value (Hi) - Expr_Value (Lo) + 1)
* Component_Size (E);
-- Do not overwrite a different value of 'Size specified
-- explicitly by the user. In that case, also do not set Esize.
-- explicitly by the user. In that case, also do not set
-- Esize.
if Unknown_RM_Size (E) or else RM_Size (E) = Siz then
Set_RM_Size (E, Siz);
@ -527,6 +536,7 @@ package body Layout is
Set_Esize (E, Siz);
end if;
end if;
end if;
end;
end if;
end if;