diff mbox series

[Ada] Add small sanity check for package freezing

Message ID 4337851.dmJWfxUUrQ@polaris
State New
Headers show
Series [Ada] Add small sanity check for package freezing | expand

Commit Message

Eric Botcazou Dec. 13, 2017, 9:18 a.m. UTC
In order to implement the complex elaboration rules of the languages, the 
front-end inserts freeze nodes in the expanded code to mark spots from where 
package bodies can be translated by gigi.  It can do so for packages with or 
without bodies now so a small sanity check is necessary.

Tested on x86_64-suse-linux, applied on the mainline and 7 branch.


2017-12-13  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (process_freeze_entity): Be prepared for a
	package without body.
diff mbox series

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 255578)
+++ gcc-interface/trans.c	(working copy)
@@ -8718,12 +8718,12 @@  process_freeze_entity (Node_Id gnat_node
   const Entity_Kind kind = Ekind (gnat_entity);
   tree gnu_old, gnu_new;
 
-  /* If this is a package, we need to generate code for the package.  */
+  /* If this is a package, generate code for the package body, if any.  */
   if (kind == E_Package)
     {
-      insert_code_for
-	(Parent (Corresponding_Body
-		 (Parent (Declaration_Node (gnat_entity)))));
+      const Node_Id gnat_decl = Parent (Declaration_Node (gnat_entity));
+      if (Present (Corresponding_Body (gnat_decl)))
+	insert_code_for (Parent (Corresponding_Body (gnat_decl)));
       return;
     }