c-family: ICE with -Wconversion and A ?: B [PR101030]
commit5db9ce171019f8915885cebd5cc5f4101bb926e6
authorMarek Polacek <polacek@redhat.com>
Tue, 29 Mar 2022 18:36:55 +0000 (29 14:36 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 30 Mar 2022 14:23:06 +0000 (30 10:23 -0400)
tree96da600dda585dd7edec8d835db72f59ed4e18f5
parent3aaf9bf77047aecc23072fe3db7f13ecff72a7cf
c-family: ICE with -Wconversion and A ?: B [PR101030]

This patch fixes a crash in conversion_warning on a null expression.
It is null because the testcase uses the GNU A ?: B extension.  We
could also use op0 instead of op1 in this case, but it doesn't seem
to be necessary.

PR c++/101030

gcc/c-family/ChangeLog:

* c-warn.cc (conversion_warning) <case COND_EXPR>: Don't call
conversion_warning when OP1 is null.

gcc/testsuite/ChangeLog:

* g++.dg/ext/cond5.C: New test.
gcc/c-family/c-warn.cc
gcc/testsuite/g++.dg/ext/cond5.C [new file with mode: 0644]