Avoid calling End_Label on the Empty node.
Tested on x86_64-pc-linux-gnu, committed on trunk
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.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -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;