------- Comment #5 from jakub at gcc dot gnu dot org 2007-11-22 23:04 -------
See the shorten code in e.g. c-typeck.c's build_binary_op.
I think there are two possible fixes:
1) if shortening (i.e. final_type != result_type) don't convert_and_check
to result_type, but instead convert to result_type, and
warnings_for_convert_and_check to final_type
2) in conversion_warning's != REAL_CST != INTEGER_CST
TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
&& TREE_CODE (type) == INTEGER_TYPE case use get_narrower to see if
expr is zero or sign extended some smaller type.
If say type is unsigned char and expr is (int) b where unsigned char b;
then we shouldn't really warn, the conversions together can't alter
its value, nor change sign etc.
I think 2) is strongly preferrable.
Will try a patch tomorrow^H^H^H^H^H^H^H^Htoday.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-11-22 22:43:19 |2007-11-22 23:04:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34198