(convert_and_check): Don't warn converting 0xff
authorRichard Stallman <rms@gnu.org>
Sat, 30 Oct 1993 08:34:05 +0000 (08:34 +0000)
committerRichard Stallman <rms@gnu.org>
Sat, 30 Oct 1993 08:34:05 +0000 (08:34 +0000)
to a signed char, etc., unless pedantic.

From-SVN: r5944

gcc/c-common.c

index 86f4ed7a4664ba9efba3f20dffb1ddfeda069288..a6e78260841a3e60760f23c81b811a8a62153605 100644 (file)
@@ -1019,7 +1019,12 @@ convert_and_check (type, expr)
          if (!(TREE_UNSIGNED (type) < TREE_UNSIGNED (TREE_TYPE (expr))
                && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
                && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr))))
-           warning ("overflow in implicit constant conversion");
+           /* If EXPR fits in the unsigned version of TYPE,
+              don't warn unless pedantic.  */
+           if (pedantic
+               || TREE_UNSIGNED (type)
+               || ! int_fits_type_p (expr, unsigned_type (type)))
+             warning ("overflow in implicit constant conversion");
        }
       else
        unsigned_conversion_warning (t, expr);