]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: Handle RAW_DATA_CST in complete_array_type [PR117313]
authorJakub Jelinek <jakub@redhat.com>
Tue, 29 Oct 2024 19:14:09 +0000 (20:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Oct 2024 19:14:09 +0000 (20:14 +0100)
commit28b7aed124d4d86be552f24469c2cfa59a49edaf
tree8af23ef0151e2ddc15494f50222d356956f4d9e1
parente6d21cbf5cf035b6fa9946a4321f87cbcfa9f275
c-family: Handle RAW_DATA_CST in complete_array_type [PR117313]

The following testcase ICEs, because
add_flexible_array_elts_to_size -> complete_array_type
is done only after braced_lists_to_strings which optimizes
RAW_DATA_CST surrounded by INTEGER_CST into a larger RAW_DATA_CST
covering even the boundaries, while I thought it is done before
that.
So, RAW_DATA_CST now can be the last constructor_elt in a CONSTRUCTOR
and so we need the function to take it into account (handle it as
RAW_DATA_CST standing for RAW_DATA_LENGTH consecutive elements).

The function wants to support both CONSTRUCTORs without indexes and with
them (for non-RAW_DATA_CST elts it was just adding 1 for the current
index).  So, if the RAW_DATA_CST elt has ce->index, we need to add
RAW_DATA_LENGTH (ce->value) - 1, while if it doesn't (and it isn't cnt == 0
case where curindex is 0), add that plus 1, i.e. RAW_DATA_LENGTH (ce->value).

2024-10-29  Jakub Jelinek  <jakub@redhat.com>

PR c/117313
gcc/c-family/
* c-common.cc (complete_array_type): For RAW_DATA_CST elements
advance curindex by RAW_DATA_LENGTH or one less than that if
ce->index is non-NULL.  Handle even the first element if
it is RAW_DATA_CST.  Formatting fix.
gcc/testsuite/
* c-c++-common/init-6.c: New test.
gcc/c-family/c-common.cc
gcc/testsuite/c-c++-common/init-6.c [new file with mode: 0644]