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.
This commit is contained in:
rillig 2021-06-20 18:38:12 +00:00
parent a389762758
commit 38b6e324bc
3 changed files with 9 additions and 8 deletions

View File

@ -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'');
}

View File

@ -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]

View File

@ -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 {