diff options
author | Richard Stallman <rms@gnu.org> | 1992-10-29 06:06:53 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1992-10-29 06:06:53 +0000 |
commit | c9b7f31c92fea6288955105883342fe61aab788f (patch) | |
tree | d68a96b9fc6e083572db64d7b0bb5c72d4783a9b /gcc | |
parent | d92761c01547fe487de4e3a9249e5189ee8cb0fd (diff) | |
download | gcc-c9b7f31c92fea6288955105883342fe61aab788f.zip gcc-c9b7f31c92fea6288955105883342fe61aab788f.tar.gz gcc-c9b7f31c92fea6288955105883342fe61aab788f.tar.bz2 |
(build_c_cast): Don't warn about size change between
pointer and integer if the value is constant.
From-SVN: r2645
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 9acec10..f06423e 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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); |