c-family: Avoid ICE on va_arg [PR99324]
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Mar 2021 08:55:19 +0000 (09:55 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 3 Mar 2021 08:55:19 +0000 (09:55 +0100)
commitba09d11a9d0ae2382bab715b102a7746d20dea6d
treef44640d66c203477a0a7bf3fc80e292093920e72
parentb5040344b9ca609e19ee59ba56cd4af9697a1692
c-family: Avoid ICE on va_arg [PR99324]

build_va_arg calls the middle-end mark_addressable, which e.g. requires that
cfun is non-NULL.  The following patch calls instead c_common_mark_addressable_vec
which is the c-family variant similarly to the FE c_mark_addressable and
cxx_mark_addressable, except that it doesn't error on addresses of register
variables.  As the taking of the address is artificial for the .VA_ARG
ifn and when that is lowered goes away, it is similar case to the vector
subscripting for which c_common_mark_addressable_vec has been added.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR c/99324
* c-common.c (build_va_arg): Call c_common_mark_addressable_vec
instead of mark_addressable.  Fix a comment typo -
neutrallly -> neutrally.

* gcc.c-torture/compile/pr99324.c: New test.
gcc/c-family/c-common.c
gcc/testsuite/gcc.c-torture/compile/pr99324.c [new file with mode: 0644]