(build_c_cast): Don't warn about size change between
authorRichard Stallman <rms@gnu.org>
Thu, 29 Oct 1992 06:06:53 +0000 (06:06 +0000)
committerRichard Stallman <rms@gnu.org>
Thu, 29 Oct 1992 06:06:53 +0000 (06:06 +0000)
pointer and integer if the value is constant.

From-SVN: r2645

gcc/c-typeck.c

index 9acec10a47e3345862dcfbae834359cfdbb2f73d..f06423e61ef7e6117254371ff00ee992e2b7326b 100644 (file)
@@ -3752,15 +3752,20 @@ build_c_cast (type, expr)
 
       if (TREE_CODE (type) == INTEGER_TYPE
          && TREE_CODE (otype) == POINTER_TYPE
-         && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
+         && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
+         && !TREE_CONSTANT (value))
        warning ("cast from pointer to integer of different size");
 
       if (TREE_CODE (type) == POINTER_TYPE
          && TREE_CODE (otype) == INTEGER_TYPE
          && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
+#if 0
          /* Don't warn about converting 0 to pointer,
             provided the 0 was explicit--not cast or made by folding.  */
-         && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
+         && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))
+#endif
+         /* Don't warn about converting any constant.  */
+         && !TREE_CONSTANT (value))
        warning ("cast to pointer from integer of different size");
 
       value = convert (type, value);