varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]
authorJakub Jelinek <jakub@redhat.com>
Sat, 18 Jun 2022 09:07:13 +0000 (11:07 +0200)
committerJakub Jelinek <jakub@redhat.com>
Sat, 18 Jun 2022 09:07:13 +0000 (11:07 +0200)
commitef662120177d39af5f88ffc622d90bb6ae0ca1d3
treedabad3e88d79c104b3d91d28034d0307fd0c769c
parent9991d84d2a84355fd3fc9afc89a963f45991bfa9
varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]

The following testcase ICEs because there is NON_LVALUE_EXPR (location
wrapper) around a VAR_DECL and has TYPE_MODE V2SImode and
SCALAR_INT_TYPE_MODE on that ICEs.  Or for -m32 -march=i386 TYPE_MODE
is DImode, but SCALAR_INT_TYPE_MODE still uses the raw V2SImode and ICEs
too.

2022-06-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/105998
* varasm.cc (narrowing_initializer_constant_valid_p): Check
SCALAR_INT_MODE_P instead of INTEGRAL_MODE_P, also break on
! INTEGRAL_TYPE_P and do the same check also on op{0,1}'s type.

* c-c++-common/pr105998.c: New test.
gcc/testsuite/c-c++-common/pr105998.c [new file with mode: 0644]
gcc/varasm.cc