Module Name: src Committed By: rillig Date: Sun Mar 7 18:02:45 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y lint1.h Log Message: lint: fix off-by-one error in 'case 3...5' According to the GCC documentation[1], the high end of the range is inclusive as well, which makes sense since otherwise there would be no way of specifying a range that includes the maximum representable number. Since the range is not used at all in the code, none of the tests could possibly fail. [1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html No functional change. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.164 src/usr.bin/xlint/lint1/cgram.y:1.165 --- src/usr.bin/xlint/lint1/cgram.y:1.164 Sun Mar 7 17:57:52 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Mar 7 18:02:45 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.164 2021/03/07 17:57:52 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.165 2021/03/07 18:02:45 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.164 2021/03/07 17:57:52 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.165 2021/03/07 18:02:45 rillig Exp $"); #endif #include <limits.h> @@ -1348,7 +1348,7 @@ init_expr_list: range: constant { $$.lo = toicon($1, 1); - $$.hi = $$.lo + 1; + $$.hi = $$.lo; } | constant T_ELLIPSIS constant { $$.lo = toicon($1, 1); Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.69 src/usr.bin/xlint/lint1/lint1.h:1.70 --- src/usr.bin/xlint/lint1/lint1.h:1.69 Sun Feb 28 19:24:15 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Mar 7 18:02:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.69 2021/02/28 19:24:15 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.70 2021/03/07 18:02:45 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -403,8 +403,8 @@ typedef struct control_statement { } cstk_t; typedef struct { - size_t lo; - size_t hi; + size_t lo; /* inclusive */ + size_t hi; /* inclusive */ } range_t; #include "externs1.h"