]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/c-family/c-common.c
varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of the init value.
[gcc.git] / gcc / c-family / c-common.c
index 13ed65cb0127a1479849f6b3eae9621c7c6f7f0f..4bfb14585e2a5543c8a9980c46fdf3fd7b8fed59 100644 (file)
@@ -6425,6 +6425,28 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
   return failure;
 }
 
+/* INIT is an constructor of a structure with a flexible array member.
+   Complete the flexible array member with a domain based on it's value.  */
+void
+complete_flexible_array_elts (tree init)
+{
+  tree elt, type;
+
+  if (init == NULL_TREE || TREE_CODE (init) != CONSTRUCTOR)
+    return;
+
+  if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
+    return;
+
+  elt = CONSTRUCTOR_ELTS (init)->last ().value;
+  type = TREE_TYPE (elt);
+  if (TREE_CODE (type) == ARRAY_TYPE
+      && TYPE_SIZE (type) == NULL_TREE)
+    complete_array_type (&TREE_TYPE (elt), elt, false);
+  else
+    complete_flexible_array_elts (elt);
+}
+
 /* Like c_mark_addressable but don't check register qualifier.  */
 void 
 c_common_mark_addressable_vec (tree t)
This page took 0.03729 seconds and 5 git commands to generate.