[Ada] Add assertion for Size attribute et al.

Message ID 1658397.meEJfPj24F@arcturus.home
State New
Headers show
Series
  • [Ada] Add assertion for Size attribute et al.
Related show

Commit Message

Eric Botcazou Aug. 30, 2019, 2:26 p.m.
The type to which, or the type of the object to which, it is applied must be 
frozen when the Size attribute, or a variant thereof, is processed.

Tested on x86_64-suse-linux, applied on the mainline.


2019-08-30  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Add assertion.

-- 
Eric Botcazou

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 275174)
+++ gcc-interface/trans.c	(working copy)
@@ -2351,6 +2351,9 @@  Attribute_to_gnu (Node_Id gnat_node, tree *gnu_res
 	    gnu_type = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_type)));
 	}
 
+      /* The type must be frozen at this point.  */
+      gcc_assert (COMPLETE_TYPE_P (gnu_type));
+
       /* If we're looking for the size of a field, return the field size.  */
       if (TREE_CODE (gnu_prefix) == COMPONENT_REF)
 	gnu_result = DECL_SIZE (TREE_OPERAND (gnu_prefix, 1));