--- p/predef.c.orig Thu Aug 17 14:41:29 2006 +++ p/predef.c Thu Aug 17 14:46:29 2006 @@ -2613,7 +2613,7 @@ case '<': { int nopad = r_num == p_EQ || r_num == p_LT; - const char *warning_str = NULL, *warning_op = NULL; + const char *warning_str = NULL; if (swapargs) { @@ -2622,20 +2622,7 @@ val = TREE_VALUE (apar); } - if (r_num == p_EQ || r_num == '=') - { - unsigned HOST_WIDE_INT l1 = get_string_length_plus_1 (val, nopad), l2 = get_string_length_plus_1 (val2, nopad); - tree c1 = PASCAL_TYPE_STRING (TREE_TYPE (val )) ? PASCAL_STRING_CAPACITY (val ) : PASCAL_STRING_LENGTH (val ); - tree c2 = PASCAL_TYPE_STRING (TREE_TYPE (val2)) ? PASCAL_STRING_CAPACITY (val2) : PASCAL_STRING_LENGTH (val2); - warning_op = invert_result ? "<>" : "="; - if (l1 > 0 && l2 > 0 && l1 != l2) - warning_str = "`%s' comparison of fixed-size strings is always %s due to different length"; - else if ((l2 > 0 && TREE_CODE (c1) == INTEGER_CST && TREE_INT_CST_LOW (c1) < l2 - 1) || - (l1 > 0 && TREE_CODE (c2) == INTEGER_CST && TREE_INT_CST_LOW (c2) < l1 - 1)) - warning_str = "`%s' string comparison is always %s because the capacity of one string is smaller than the length of the fixed-size string"; - } - - if (!warning_str && IS_STRING_CST (val) && IS_STRING_CST (val2)) + if (IS_STRING_CST (val) && IS_STRING_CST (val2)) { const char *p1, *p2; unsigned int l1, l2, r; @@ -2676,6 +2663,17 @@ retval = r ? boolean_true_node : boolean_false_node; break; } + else if (r_num == p_EQ || r_num == '=') + { + unsigned HOST_WIDE_INT l1 = get_string_length_plus_1 (val, nopad), l2 = get_string_length_plus_1 (val2, nopad); + tree c1 = PASCAL_TYPE_STRING (TREE_TYPE (val )) ? PASCAL_STRING_CAPACITY (val ) : PASCAL_STRING_LENGTH (val ); + tree c2 = PASCAL_TYPE_STRING (TREE_TYPE (val2)) ? PASCAL_STRING_CAPACITY (val2) : PASCAL_STRING_LENGTH (val2); + if (l1 > 0 && l2 > 0 && l1 != l2) + warning_str = "`%s' comparison of fixed-size strings is always %s due to different length"; + else if ((l2 > 0 && TREE_CODE (c1) == INTEGER_CST && TREE_INT_CST_LOW (c1) < l2 - 1) || + (l1 > 0 && TREE_CODE (c2) == INTEGER_CST && TREE_INT_CST_LOW (c2) < l1 - 1)) + warning_str = "`%s' string comparison is always %s because the capacity of one string is smaller than the length of the fixed-size string"; + } /* Optimize non-padding comparisons against the constant empty string */ if (!warning_str && nopad) @@ -2690,10 +2688,7 @@ else if (IS_CONSTANT_EMPTY_STRING (val2)) { if (r_num == p_LT) /* s < '' is impossible */ - { - warning_op = invert_result ? ">=" : "<"; - warning_str = "`%s' comparison against the empty string is always %s."; - } + warning_str = "`%s' comparison against the empty string is always %s."; else comp_empty = val; } @@ -2711,7 +2706,7 @@ if (warning_str) { - warning (warning_str, warning_op, invert_result ? "true" : "false"); + warning (warning_str, r_name, invert_result ? "true" : "false"); if (TREE_SIDE_EFFECTS (val) || TREE_SIDE_EFFECTS (val2)) warning (" Operand with side-effects is not evaluated."); return invert_result ? boolean_true_node : boolean_false_node; --- p/test/dave7k.pas.orig Thu Aug 3 20:29:15 2006 +++ p/test/dave7k.pas Thu Aug 17 14:13:14 2006 @@ -1,7 +1,7 @@ program comp (output); begin - if '' = ' ' { WARN } + if '' = ' ' then writeln ('true') - else writeln ('false') + else writeln ('OK') end.