aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-chkp.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2015-12-15 21:04:08 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2015-12-15 14:04:08 -0700
commit7e9a3ad30076ad8a91b8f61352aa98b417191ed5 (patch)
tree50f9efd8d71500ea8804646ff802d54fe104ece9 /gcc/tree-chkp.c
parent1f0659546bcf5b95c3263cdc73149f6c2a05ebe1 (diff)
downloadgcc-7e9a3ad30076ad8a91b8f61352aa98b417191ed5.zip
gcc-7e9a3ad30076ad8a91b8f61352aa98b417191ed5.tar.gz
gcc-7e9a3ad30076ad8a91b8f61352aa98b417191ed5.tar.bz2
struct-layout-1_generate.c: Avoid generating further fields after the first flexible array member.
gcc/testsuite/ChangeLog: 2015-12-15 Martin Sebor <msebor@redhat.com> c++/42121 c++/68478 c++/68613 c++/68689 c++/68710 * g++.dg/compat/struct-layout-1_generate.c: Avoid generating further fields after the first flexible array member. * g++.dg/ext/flexary2.C: Expect a sole flexible array member to be rejected. Add a test case exercising zero-length array. * g++.dg/ext/flexary3.C: Expect a sole flexible array member to be rejected. * g++.dg/ext/flexary.h: New file. * g++.dg/ext/flexary4.C: New file. * g++.dg/ext/flexary5.C: New file. * g++.dg/ext/flexary6.C: New file. * g++.dg/ext/flexary7.C: New file. * g++.dg/ext/flexary8.C: New file. * g++.dg/other/dump-ada-spec-2.C: Adjust to reflect flexible array members. * g++.dg/parse/pr43765.C: Add a member to make a struct with a flexible array member valid. Adjust expected error message. * g++.dg/torture/pr64280.C: Expect a sole flexible array member to be rejected. * g++.dg/torture/pr64312.C: Add a member to make a struct with a flexible array member valid. * g++.dg/ubsan/object-size-1.C: Adjust expected diagnostic. gcc/cp/ChangeLog: 2015-12-15 Martin Sebor <msebor@redhat.com> c++/42121 c++/68478 c++/68613 c++/68689 c++/68710 * class.c (walk_subobject_offsets): Avoid assuming type domain is non-null or has an upper bound. (layout_class_type): Include type size in error message. (flexmems_t): New type. (field_nonempty_p, find_flexarrays, diagnose_flexarrays) (check_flexarrays): New functions. (finish_struct_1): Call check_flexarrays. * decl.c (compute_array_index_type): Distinguish flexible array members from zero-length arrays. (grokdeclarator): Reject flexible array members in unions. Avoid rejecting members of incomplete types that are flexible array members. * error.c (dump_type_suffix): Handle flexible array members with null upper bound. * init.c (perform_member_init): Same. * pt.c (instantiate_class_template_1): Allow flexible array members. (tsubst): Handle flexible array members with null upper bound. * typeck2.c (digest_init_r): Warn for initialization of flexible array members. (process_init_constructor_record): Handle flexible array members. gcc/ChangeLog: 2015-12-15 Martin Sebor <msebor@redhat.com> c++/42121 * tree-chkp.c (chkp_find_bound_slots_1): Handle flexible array members. * tree.c (type_contains_placeholder_1): Avoid assuming type has a non-null domain or an upper bound to handle flexible array members. * varasm.c (output_constructor_regular_field): Same. (output_constructor): Set min_index to integer_zero_node rather than null when a type has no domain to avoid crashing later. From-SVN: r231665
Diffstat (limited to 'gcc/tree-chkp.c')
-rw-r--r--gcc/tree-chkp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index b666e97..3768bc8 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -1664,8 +1664,10 @@ chkp_find_bound_slots_1 (const_tree type, bitmap have_bound,
offs + field_offs);
}
}
- else if (TREE_CODE (type) == ARRAY_TYPE)
+ else if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type))
{
+ /* The object type is an array of complete type, i.e., other
+ than a flexible array. */
tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
tree etype = TREE_TYPE (type);
HOST_WIDE_INT esize = TREE_INT_CST_LOW (TYPE_SIZE (etype));