diff options
author | Richard Stallman <rms@gnu.org> | 1992-03-22 20:04:27 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1992-03-22 20:04:27 +0000 |
commit | 2918ed3c3e043a75246fe6a2476f75d954a0ac2f (patch) | |
tree | 479eeb877f644e8dd6b83f485ce576d3bf1ec6d0 /gcc | |
parent | bd0725f32ba21999f0d39cde6d35b6b9e7f881f3 (diff) | |
download | gcc-2918ed3c3e043a75246fe6a2476f75d954a0ac2f.zip gcc-2918ed3c3e043a75246fe6a2476f75d954a0ac2f.tar.gz gcc-2918ed3c3e043a75246fe6a2476f75d954a0ac2f.tar.bz2 |
*** empty log message ***
From-SVN: r568
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-typeck.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 983b330..edacf2c 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3666,7 +3666,10 @@ build_c_cast (type, expr) if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == INTEGER_TYPE - && TYPE_PRECISION (type) != TYPE_PRECISION (otype)) + && TYPE_PRECISION (type) != TYPE_PRECISION (otype) + /* 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))) warning ("cast to pointer from integer of different size"); value = convert (type, value); @@ -3953,7 +3956,9 @@ convert_for_assignment (type, rhs, errtype, funname, parmnum) } else if (codel == POINTER_TYPE && coder == INTEGER_TYPE) { - if (! integer_zerop (rhs)) + /* An explicit constant 0 can convert to a pointer, + but not a 0 that results from casting or folding. */ + if (! (TREE_CODE (rhs) == INTEGER_CST && integer_zerop (rhs))) { warn_for_assignment ("%s makes pointer from integer without a cast", get_spelling (errtype), funname, parmnum); |