Module Name: src
Committed By: rillig
Date: Sun Jun 20 18:38:12 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: lex_wide_char.c lex_wide_char.exp
src/usr.bin/xlint/lint1: lex.c
Log Message:
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial
commit in 1995.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/lex_wide_char.c \
src/tests/usr.bin/xlint/lint1/lex_wide_char.exp
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/xlint/lint1/lex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/lex_wide_char.c
diff -u src/tests/usr.bin/xlint/lint1/lex_wide_char.c:1.1 src/tests/usr.bin/xlint/lint1/lex_wide_char.c:1.2
--- src/tests/usr.bin/xlint/lint1/lex_wide_char.c:1.1 Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_wide_char.c Sun Jun 20 18:38:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_wide_char.c,v 1.1 2021/06/19 08:30:08 rillig Exp $ */
+/* $NetBSD: lex_wide_char.c,v 1.2 2021/06/20 18:38:12 rillig Exp $ */
# 3 "lex_wide_char.c"
/*
@@ -12,7 +12,7 @@ void sink(int);
void
test(void)
{
- /* TODO: expect+1: empty character constant */
+ /* expect+1: empty character constant */
sink(L'');
sink(L'a');
@@ -22,7 +22,6 @@ test(void)
/* UTF-8 */
/* expect+1: too many characters in character constant */
sink(L'รค');
- /* rescue the parser: ' */
/* GCC extension */
/* expect+1: dubious escape \e */
@@ -37,6 +36,6 @@ test(void)
/* newline */
sink(L'\n');
- /* TODO: expect+1: empty character constant */
+ /* expect+1: empty character constant */
sink(L'');
}
Index: src/tests/usr.bin/xlint/lint1/lex_wide_char.exp
diff -u src/tests/usr.bin/xlint/lint1/lex_wide_char.exp:1.1 src/tests/usr.bin/xlint/lint1/lex_wide_char.exp:1.2
--- src/tests/usr.bin/xlint/lint1/lex_wide_char.exp:1.1 Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_wide_char.exp Sun Jun 20 18:38:12 2021
@@ -1,2 +1,4 @@
+lex_wide_char.c(16): error: empty character constant [73]
lex_wide_char.c(24): error: too many characters in character constant [71]
-lex_wide_char.c(29): warning: dubious escape \e [79]
+lex_wide_char.c(28): warning: dubious escape \e [79]
+lex_wide_char.c(40): error: empty character constant [73]
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.41 src/usr.bin/xlint/lint1/lex.c:1.42
--- src/usr.bin/xlint/lint1/lex.c:1.41 Sat Jun 19 20:25:58 2021
+++ src/usr.bin/xlint/lint1/lex.c Sun Jun 20 18:38:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.41 2021/06/19 20:25:58 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.41 2021/06/19 20:25:58 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 rillig Exp $");
#endif
#include <ctype.h>
@@ -881,7 +881,7 @@ lex_wide_character_constant(void)
if (c == -2) {
/* unterminated character constant */
error(253);
- } else if (c == 0) {
+ } else if (i == 0) {
/* empty character constant */
error(73);
} else {