diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-03-11 23:08:38 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-03-11 23:08:38 +0100 |
commit | afb46540d3921e96c4cd7ba8fa2c8b0901759455 (patch) | |
tree | 2ebd0b2dae2dc0d4bdf4778322c2d91e7e0edd58 /gcc/d | |
parent | 799ed87bcf6b5bede87311717adac5fb88fd7722 (diff) | |
download | gcc-afb46540d3921e96c4cd7ba8fa2c8b0901759455.zip gcc-afb46540d3921e96c4cd7ba8fa2c8b0901759455.tar.gz gcc-afb46540d3921e96c4cd7ba8fa2c8b0901759455.tar.bz2 |
c: Don't emit -Wunterminated-string-initialization warning for multi-dimensional nonstring array initializers [PR117178]
My/Kees' earlier patches adjusted -Wunterminated-string-initialization
warning so that it doesn't warn about initializers of nonstring decls
and that nonstring attribute is allowed on multi-dimensional arrays.
Unfortunately as this testcase shows, we still warn about initializers
of multi-dimensional array nonstring decls.
The problem is that in that case field passed to output_init_element
is actually INTEGER_CST, index into the array.
For RECORD_OR_UNION_TYPE_P (constructor_type) field is a FIELD_DECL
which we want to use, but otherwise (in arrays) IMHO we want to use
constructor_fields (which is the innermost FIELD_DECL whose part
is being initialized), or - if that is NULL - constructor_decl, the
whole decl being initialized with multi-dimensional array type.
2025-03-11 Jakub Jelinek <jakub@redhat.com>
PR c/117178
* c-typeck.cc (output_init_element): Pass field to digest_init
only for record/union types, otherwise pass constructor_fields
if non-NULL and constructor_decl if constructor_fields is NULL.
* gcc.dg/Wunterminated-string-initialization-2.c: New test.
Diffstat (limited to 'gcc/d')
0 files changed, 0 insertions, 0 deletions