[Ada] Fix latent bug in set_end_locus_from_node

gcc/ada/

	* gcc-interface/trans.c (set_end_locus_from_node): Check that
	Handled_Statement_Sequence is not Empty before calling
	End_Label, because the Empty node has no End_Label, and
	depending on the exact node layout chosen by gen_il, calling
	End_Label might crash, or might work OK by accident.
This commit is contained in:
Bob Duff 2021-08-11 07:44:31 -04:00 committed by Pierre-Marie de Rodat
parent 07ad659daf
commit 650ad524d8

View File

@ -10507,10 +10507,15 @@ set_end_locus_from_node (tree gnu_node, Node_Id gnat_node)
case N_Package_Body:
case N_Subprogram_Body:
case N_Block_Statement:
gnat_end_label = End_Label (Handled_Statement_Sequence (gnat_node));
if (Present (Handled_Statement_Sequence (gnat_node)))
gnat_end_label = End_Label (Handled_Statement_Sequence (gnat_node));
else
gnat_end_label = Empty;
break;
case N_Package_Declaration:
gcc_checking_assert (Present (Specification (gnat_node)));
gnat_end_label = End_Label (Specification (gnat_node));
break;