Fix thinko in new warning on type punning for storage order purposes
commita589877a0036fc2f66b7a957859940c53efdc7c9
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 6 Jun 2021 09:37:45 +0000 (6 11:37 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Sun, 6 Jun 2021 09:41:30 +0000 (6 11:41 +0200)
treea6bc26893ec860b9b4411e2ef71520937c894b14
parent28c62475050d2ac6c243580e1130a87308e1e907
Fix thinko in new warning on type punning for storage order purposes

In C, unlike in Ada, the storage order of arrays is that of their component
type, so you need to look at it when deciding to warn.  And the PR complains
about a bogus warning on the assignment of a pointer returned by alloca or
malloc, so this also fixes that.

gcc/c
PR c/100920
* c-decl.c (finish_struct): Fix thinko in previous change.
* c-typeck.c (convert_for_assignment): Do not warn on pointer
assignment and initialization for storage order purposes if the
RHS is a call to a DECL_IS_MALLOC function.
gcc/testsuite/
* gcc.dg/sso-14.c: New test.
gcc/c/c-decl.c
gcc/c/c-typeck.c
gcc/testsuite/gcc.dg/sso-14.c [new file with mode: 0644]