This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Suggested rewording of warning message
- To: Horst von Brand <vonbrand at sleipnir dot valparaiso dot cl>
- Subject: Re: Suggested rewording of warning message
- From: Zack Weinberg <zack at rabi dot columbia dot edu>
- Date: Mon, 16 Nov 1998 18:00:25 -0500
- cc: egcs-patches at cygnus dot com
On Fri, 13 Nov 1998 11:36:30 -0400, Horst von Brand wrote:
>Zack Weinberg <zack@rabi.columbia.edu> said:
>
>[...]
>
>> Since this is a warning about a test, how about this:
>>
>> warning: condition `unsigned value < 0' is always false
>>
>> or, if possible, this:
>>
>> warning: unsigned comparison `x < 0' is always false
>>
>> where x is the variable being compared against 0.
>
>x might be an expression, not a variable. Perhaps:
>
>warning: unsigned comparison < 0 is always false
>
>And how about >= 0? It should be reworded too.
Yeah, and there are a couple others like this. Here's a patch.
zw
1998-11-16 17:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-common.c: Change warning messages to say `comparison is
always true' or `comparison is always false' instead of the
confusing `is always 0', `is always 1'.
============================================================
Index: c-common.c
--- c-common.c 1998/10/31 20:44:46 1.43
+++ c-common.c 1998/11/16 22:09:02
@@ -2512,18 +2512,18 @@
/* This is the case of (char)x >?< 0x80, which people used to use
expecting old C compilers to change the 0x80 into -0x80. */
if (val == boolean_false_node)
- warning ("comparison is always 0 due to limited range of data type");
+ warning ("comparison is always false due to limited range of data type");
if (val == boolean_true_node)
- warning ("comparison is always 1 due to limited range of data type");
+ warning ("comparison is always true due to limited range of data type");
}
if (!min_lt && unsignedp0 && TREE_CODE (primop0) != INTEGER_CST)
{
/* This is the case of (unsigned char)x >?< -1 or < 0. */
if (val == boolean_false_node)
- warning ("comparison is always 0 due to limited range of data type");
+ warning ("comparison is always false due to limited range of data type");
if (val == boolean_true_node)
- warning ("comparison is always 1 due to limited range of data type");
+ warning ("comparison is always true due to limited range of data type");
}
if (val != 0)
@@ -2589,7 +2589,7 @@
&& ! (TREE_CODE (primop0) == INTEGER_CST
&& ! TREE_OVERFLOW (convert (signed_type (type),
primop0))))
- warning ("unsigned value >= 0 is always 1");
+ warning ("comparison of unsigned expression >= 0 is always true");
value = boolean_true_node;
break;
@@ -2598,7 +2598,7 @@
&& ! (TREE_CODE (primop0) == INTEGER_CST
&& ! TREE_OVERFLOW (convert (signed_type (type),
primop0))))
- warning ("unsigned value < 0 is always 0");
+ warning ("comparison of unsigned expression < 0 is always false");
value = boolean_false_node;
break;