set DECL_SIZE_UNIT for zero-sized fields
authorAlexandre Oliva <oliva@adacore.com>
Fri, 27 Sep 2019 01:59:55 +0000 (01:59 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 27 Sep 2019 01:59:55 +0000 (01:59 +0000)
Zero-sized fields do not get processed by finish_record_type: they're
removed from the field list before and reinserted after, so their
DECL_SIZE_UNIT remains unset, causing the translation of assignment
statements with use_memset_p, in quite unusual circumstances, to use a
NULL_TREE as the memset length.  This patch sets DECL_SIZE_UNIT for
the zero-sized fields, that don't go through language-independent
layout, in language-specific layout.

for  gcc/ada/ChangeLog

* gcc-interface/decl.c (components_to_record): Set
DECL_SIZE_UNIT for zero-sized fields.

From-SVN: r276173

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index a5f3843..8e5a19b 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-26  Alexandre Oliva <oliva@adacore.com>
+
+       * gcc-interface/decl.c (components_to_record): Set
+       DECL_SIZE_UNIT for zero-sized fields.
+
 2019-09-26  Arnaud Charlet  <charlet@adacore.com>
 
        * osint.adb (OS_Time_To_GNAT_Time): Remove dependency on To_C/To_Ada
index 67b938e..77c6c9f 100644 (file)
@@ -7928,6 +7928,7 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
 
       if (DECL_SIZE (gnu_field) && integer_zerop (DECL_SIZE (gnu_field)))
        {
+         DECL_SIZE_UNIT (gnu_field) = size_zero_node;
          DECL_FIELD_OFFSET (gnu_field) = size_zero_node;
          SET_DECL_OFFSET_ALIGN (gnu_field, BIGGEST_ALIGNMENT);
          DECL_FIELD_BIT_OFFSET (gnu_field) = bitsize_zero_node;