c-family: Fix problems with blender and PPC from PR 40752 patch.
authorJason Merrill <jason@redhat.com>
Wed, 22 Jan 2020 19:21:06 +0000 (14:21 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 22 Jan 2020 22:05:43 +0000 (17:05 -0500)
commit55b7df8bfb12938e7716445d4e2dc0d2ddf44bac
tree92e64d32e8dc7e2491b7d52ef5e0c3b07ef197e1
parentd9637168812939d6c9df29ce747d8d4648b37cef
c-family: Fix problems with blender and PPC from PR 40752 patch.

blender in SPEC is built with -funsigned-char, which is also the default on
PPC, and exposed -Wsign-conversion issues that weren't seen by the x86_64
testsuite.  In blender we were complaining about operands to an expression
that we didn't't previously complain about as a whole.  So only check
operands after we check the whole expression.  Also, to fix the PR 40752
testcases on -funsigned-char targets, don't consider -Wsign-conversion for
the second operand of PLUS_EXPR, especially since fold changes
"x - 5" to "x + (-5)".  And don't use SCHAR_MAX with plain char.

PR testsuite/93391 - PR 40752 test fails with unsigned plain char.
PR c++/40752
* c-warn.c (conversion_warning): Check operands only after checking
the whole expression.  Don't check second operand of + for sign.
gcc/c-family/ChangeLog
gcc/c-family/c-warn.c
gcc/testsuite/c-c++-common/Wconversion-pr40752.c
gcc/testsuite/c-c++-common/Wconversion-pr40752a.c
gcc/testsuite/c-c++-common/Wconversion-pr40752b.c [new file with mode: 0644]