+2018-09-06 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of
+ the init value.
+
2018-09-06 Will Schmidt <will_schmidt@vnet.ibm.com>
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for
+2018-09-06 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * c-common.c (complete_flexible_array_elts): New helper function.
+ * c-common.h (complete_flexible_array_elts): Declare.
+
2018-09-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-common.c (braced_list_to_string): Remove eval parameter.
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)
tree_code ctx = ERROR_MARK);
extern int complete_array_type (tree *, tree, bool);
+extern void complete_flexible_array_elts (tree);
extern tree builtin_type_for_size (int, bool);
+2018-09-06 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * c-decl.c (finish_decl): Call complete_flexible_array_elts.
+
2018-09-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-decl.c (finish_decl): Call braced_list_to_string here ...
if (init && TREE_CODE (init) == CONSTRUCTOR)
add_flexible_array_elts_to_size (decl, init);
+ complete_flexible_array_elts (DECL_INITIAL (decl));
+
if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
&& COMPLETE_TYPE_P (TREE_TYPE (decl)))
layout_decl (decl, 0);
+2018-09-06 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * decl.c (check_initializer): Call cp_complete_array_type.
+
2018-09-05 Marek Polacek <polacek@redhat.com>
PR c++/87109, wrong overload with ref-qualifiers.
init_code = store_init_value (decl, init, cleanups, flags);
+ if (DECL_INITIAL (decl)
+ && TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR
+ && !vec_safe_is_empty (CONSTRUCTOR_ELTS (DECL_INITIAL (decl))))
+ {
+ tree elt = CONSTRUCTOR_ELTS (DECL_INITIAL (decl))->last ().value;
+ if (TREE_CODE (TREE_TYPE (elt)) == ARRAY_TYPE
+ && TYPE_SIZE (TREE_TYPE (elt)) == NULL_TREE)
+ cp_complete_array_type (&TREE_TYPE (elt), elt, false);
+ }
+
if (pedantic && TREE_CODE (type) == ARRAY_TYPE
&& DECL_INITIAL (decl)
&& TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
on the chain is a TYPE_DECL of the enclosing struct. */
const_tree next = DECL_CHAIN (local->field);
gcc_assert (!fieldsize || !next || TREE_CODE (next) != FIELD_DECL);
+ tree size = TYPE_SIZE_UNIT (TREE_TYPE (local->val));
+ gcc_checking_assert (compare_tree_int (size, fieldsize) == 0);
}
else
fieldsize = tree_to_uhwi (DECL_SIZE_UNIT (local->field));