c-family: Tweak -Woverflow diagnostic
commit1cd3faf5dddb3cbfa2ed308ecf3db4f70bff337e
authorMarek Polacek <polacek@redhat.com>
Wed, 30 Mar 2022 20:59:33 +0000 (30 16:59 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 4 May 2022 20:10:09 +0000 (4 16:10 -0400)
tree1342bb9e55c0fdfc47b5370c4af01ed3ffb566ee
parenta733dea9e7c39352ce9f72059938833eaa819467
c-family: Tweak -Woverflow diagnostic

When g++ emits

warning: overflow in conversion from 'int' to 'char' changes value from '300' to '',''

for code like "char c = 300;" it might raise a few eyebrows.  With this
warning we're not interested in the ASCII representation of the char, only
the numerical value, so convert constants of type char to int.  It looks
like this conversion only needs to be done for char_type_node.

gcc/c-family/ChangeLog:

* c-warn.cc (warnings_for_convert_and_check): Convert constants of type
char to int.

gcc/testsuite/ChangeLog:

* c-c++-common/Wconversion-1.c: New test.
gcc/c-family/c-warn.cc
gcc/testsuite/c-c++-common/Wconversion-1.c [new file with mode: 0644]