middle-end: Reject flexible array members in __builtin_clear_padding [PR97943]
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Nov 2020 09:37:58 +0000 (10:37 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 25 Nov 2020 09:37:58 +0000 (10:37 +0100)
commita7285c8659689e9ade53fcb996b26d874455a4f3
tree5db8400816f1cad1b376e8d8f448dfef057be0fa
parent1e2c9a2761097a6758b6aaaf612d629aa7e9febf
middle-end: Reject flexible array members in __builtin_clear_padding [PR97943]

As mentioned in the PR, we currently ICE on flexible array members in
structs and unions during __builtin_clear_padding processing.

Jason said in the PR he'd prefer an error in these cases over forcefully
handling it as [0] arrays (everything is padding then) or consider the
arrays to have as many whole elements as would fit into the tail padding.

So, this patch implements that.

2020-11-25  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/97943
* gimple-fold.c (clear_padding_union, clear_padding_type): Error on and
ignore flexible array member fields.  Ignore fields with
error_mark_node type.

* c-c++-common/builtin-clear-padding-2.c: New test.
* c-c++-common/builtin-clear-padding-3.c: New test.
* g++.dg/ext/builtin-clear-padding-1.C: New test.
* gcc.dg/builtin-clear-padding-2.c: New test.
gcc/gimple-fold.c
gcc/testsuite/c-c++-common/builtin-clear-padding-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/builtin-clear-padding-3.c [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/builtin-clear-padding-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/builtin-clear-padding-2.c [new file with mode: 0644]