mirror of git://gcc.gnu.org/git/gcc.git
varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of the init value.
* varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of the init value. * c-common.c (complete_flexible_array_elts): New helper function. * c-common.h (complete_flexible_array_elts): Declare. * c-decl.c (finish_decl): Call complete_flexible_array_elts. * decl.c (check_initializer): Call cp_complete_array_type. From-SVN: r264147
This commit is contained in:
parent
6847c656b4
commit
6d9001072d
|
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1038,6 +1038,7 @@ extern tree fold_offsetof (tree, tree = size_type_node,
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
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 ...
|
||||
|
|
|
|||
|
|
@ -5042,6 +5042,8 @@ finish_decl (tree decl, location_t init_loc, tree init,
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -6478,6 +6478,16 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -5160,6 +5160,8 @@ output_constructor_regular_field (oc_local_state *local)
|
|||
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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue