Module Name:    src
Committed By:   rillig
Date:           Tue Jun 29 07:17:43 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: lex_char.c lex_char.exp msg_076.c
            msg_076.exp msg_077.c msg_077.exp msg_080.c msg_080.exp msg_082.c
            msg_250.c msg_250.exp msg_251.c msg_251.exp msg_253.c msg_253.exp
            msg_254.c msg_254.exp msg_262.c msg_262.exp msg_263.c msg_263.exp

Log Message:
tests/lint: add tests for the lexical analysis


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lex_char.c \
    src/tests/usr.bin/xlint/lint1/lex_char.exp \
    src/tests/usr.bin/xlint/lint1/msg_076.c \
    src/tests/usr.bin/xlint/lint1/msg_076.exp \
    src/tests/usr.bin/xlint/lint1/msg_077.c \
    src/tests/usr.bin/xlint/lint1/msg_077.exp \
    src/tests/usr.bin/xlint/lint1/msg_080.c \
    src/tests/usr.bin/xlint/lint1/msg_080.exp \
    src/tests/usr.bin/xlint/lint1/msg_250.c \
    src/tests/usr.bin/xlint/lint1/msg_250.exp \
    src/tests/usr.bin/xlint/lint1/msg_251.c \
    src/tests/usr.bin/xlint/lint1/msg_251.exp \
    src/tests/usr.bin/xlint/lint1/msg_253.c \
    src/tests/usr.bin/xlint/lint1/msg_253.exp \
    src/tests/usr.bin/xlint/lint1/msg_254.c \
    src/tests/usr.bin/xlint/lint1/msg_254.exp \
    src/tests/usr.bin/xlint/lint1/msg_262.c \
    src/tests/usr.bin/xlint/lint1/msg_262.exp \
    src/tests/usr.bin/xlint/lint1/msg_263.c \
    src/tests/usr.bin/xlint/lint1/msg_263.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_082.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_char.c
diff -u src/tests/usr.bin/xlint/lint1/lex_char.c:1.2 src/tests/usr.bin/xlint/lint1/lex_char.c:1.3
--- src/tests/usr.bin/xlint/lint1/lex_char.c:1.2	Sun Jun 20 18:23:07 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.c	Tue Jun 29 07:17:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_char.c,v 1.2 2021/06/20 18:23:07 rillig Exp $	*/
+/*	$NetBSD: lex_char.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "lex_char.c"
 
 /*
@@ -34,9 +34,27 @@ test(void)
 	/* octal */
 	sink('\177');
 
-	/* newline */
-	sink('\n');
-
 	/* expect+1: empty character constant */
 	sink('');
+
+	/* U+0007 alarm/bell */
+	sink('\a');
+
+	/* U+0008 backspace */
+	sink('\b');
+
+	/* U+0009 horizontal tabulation */
+	sink('\t');
+
+	/* U+000A line feed */
+	sink('\n');
+
+	/* U+000B vertical tabulation */
+	sink('\v');
+
+	/* U+000C form feed */
+	sink('\f');
+
+	/* U+000D carriage return */
+	sink('\r');
 }
Index: src/tests/usr.bin/xlint/lint1/lex_char.exp
diff -u src/tests/usr.bin/xlint/lint1/lex_char.exp:1.2 src/tests/usr.bin/xlint/lint1/lex_char.exp:1.3
--- src/tests/usr.bin/xlint/lint1/lex_char.exp:1.2	Sun Jun 20 18:23:07 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.exp	Tue Jun 29 07:17:43 2021
@@ -2,4 +2,4 @@ lex_char.c(16): error: empty character c
 lex_char.c(25): warning: multi-character character constant [294]
 lex_char.c(25): warning: conversion of 'int' to 'char' is out of range, arg #1 [295]
 lex_char.c(29): warning: dubious escape \e [79]
-lex_char.c(41): error: empty character constant [73]
+lex_char.c(38): error: empty character constant [73]
Index: src/tests/usr.bin/xlint/lint1/msg_076.c
diff -u src/tests/usr.bin/xlint/lint1/msg_076.c:1.2 src/tests/usr.bin/xlint/lint1/msg_076.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_076.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_076.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,6 @@
-/*	$NetBSD: msg_076.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_076.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_076.c"
 
 // Test for message: character escape does not fit in character [76]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+char ch = '\777';		/* expect: [76] */
Index: src/tests/usr.bin/xlint/lint1/msg_076.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_076.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_076.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_076.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_076.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1 @@
-msg_076.c(6): error: syntax error ':' [249]
+msg_076.c(6): warning: character escape does not fit in character [76]
Index: src/tests/usr.bin/xlint/lint1/msg_077.c
diff -u src/tests/usr.bin/xlint/lint1/msg_077.c:1.2 src/tests/usr.bin/xlint/lint1/msg_077.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_077.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_077.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,25 @@
-/*	$NetBSD: msg_077.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_077.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_077.c"
 
-// Test for message: bad octal digit %c [77]
+/* Test for message: bad octal digit %c [77] */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -tw */
+
+char single_digit = '\8';	/* expect: bad octal digit 8 [77] */
+
+/*
+ * Before lex.c 1.47 from 2021-06-29, lint intended to detect a "bad octal
+ * digit" following good octal digits, but the corresponding code had an
+ * unsatisfiable guard clause.
+ *
+ * The C Reference Manual 1978, 2.4.3 "Character constants" does not mention
+ * non-octal digits, therefore this code must have been due to a particular
+ * C compiler's interpretation.  It's even wrong according to the Reference
+ * Manual to interpret '\088' as anything else than a malformed character
+ * literal.
+ *
+ * That code has been removed since nobody runs lint in traditional C mode
+ * anyway.
+ * https://mail-index.netbsd.org/tech-toolchain/2021/03/16/msg003933.html
+ */
+char several_digits = '\08';
Index: src/tests/usr.bin/xlint/lint1/msg_077.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_077.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_077.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_077.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_077.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1 @@
-msg_077.c(6): error: syntax error ':' [249]
+msg_077.c(8): warning: bad octal digit 8 [77]
Index: src/tests/usr.bin/xlint/lint1/msg_080.c
diff -u src/tests/usr.bin/xlint/lint1/msg_080.c:1.2 src/tests/usr.bin/xlint/lint1/msg_080.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_080.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_080.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,9 @@
-/*	$NetBSD: msg_080.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_080.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_080.c"
 
 // Test for message: dubious escape \%o [80]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+3: dubious escape \342 [80] */ /* FIXME: Why 342? */
+/* expect+2: multi-character character constant [294] */
+/* expect+1: initializer does not fit */
+char backslash_delete = '\⌂';
Index: src/tests/usr.bin/xlint/lint1/msg_080.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_080.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_080.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_080.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_080.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1,3 @@
-msg_080.c(6): error: syntax error ':' [249]
+msg_080.c(9): warning: dubious escape \342 [80]
+msg_080.c(9): warning: multi-character character constant [294]
+msg_080.c(9): warning: initializer does not fit [178]
Index: src/tests/usr.bin/xlint/lint1/msg_250.c
diff -u src/tests/usr.bin/xlint/lint1/msg_250.c:1.2 src/tests/usr.bin/xlint/lint1/msg_250.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_250.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_250.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_250.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_250.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_250.c"
 
 // Test for message: unknown character \%o [250]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+@deprecated			/* expect: unknown character \100 [250] */
+char *gets(void);		/* expect: syntax error 'char' [249] */
Index: src/tests/usr.bin/xlint/lint1/msg_250.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_250.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_250.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_250.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_250.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1,2 @@
-msg_250.c(6): error: syntax error ':' [249]
+msg_250.c(6): error: unknown character \100 [250]
+msg_250.c(7): error: syntax error 'char' [249]
Index: src/tests/usr.bin/xlint/lint1/msg_251.c
diff -u src/tests/usr.bin/xlint/lint1/msg_251.c:1.2 src/tests/usr.bin/xlint/lint1/msg_251.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_251.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_251.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,10 @@
-/*	$NetBSD: msg_251.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_251.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_251.c"
 
 // Test for message: malformed integer constant [251]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: malformed integer constant */
+int lll = 123LLL;
+
+/* expect+1: malformed integer constant */
+unsigned int uu = 123UU;
Index: src/tests/usr.bin/xlint/lint1/msg_251.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_251.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_251.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_251.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_251.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1,2 @@
-msg_251.c(6): error: syntax error ':' [249]
+msg_251.c(7): warning: malformed integer constant [251]
+msg_251.c(10): warning: malformed integer constant [251]
Index: src/tests/usr.bin/xlint/lint1/msg_253.c
diff -u src/tests/usr.bin/xlint/lint1/msg_253.c:1.2 src/tests/usr.bin/xlint/lint1/msg_253.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_253.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_253.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: msg_253.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_253.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_253.c"
 
 // Test for message: unterminated character constant [253]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+3: [253] */
+/* expect+2: syntax error '' */
+'
Index: src/tests/usr.bin/xlint/lint1/msg_253.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_253.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_253.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_253.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_253.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1,2 @@
-msg_253.c(6): error: syntax error ':' [249]
+msg_253.c(9): error: unterminated character constant [253]
+msg_253.c(9): error: syntax error '' [249]
Index: src/tests/usr.bin/xlint/lint1/msg_254.c
diff -u src/tests/usr.bin/xlint/lint1/msg_254.c:1.2 src/tests/usr.bin/xlint/lint1/msg_254.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_254.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_254.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,19 @@
-/*	$NetBSD: msg_254.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_254.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_254.c"
 
-// Test for message: newline in string or char constant [254]
+/* Test for message: newline in string or char constant [254] */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -tw */
+
+/*
+ * The sequence backslash-newline is a GCC extension.
+ * C99 does not allow it.
+ */
+
+/* expect+6: newline in string or char constant [254] */
+/* expect+5: unterminated string constant [258] */
+/* expect+4: syntax error '"' [249] */
+/* expect+4: newline in string or char constant [254] */
+/* expect+3: unterminated string constant [258] */
+"line1
+line2"
Index: src/tests/usr.bin/xlint/lint1/msg_254.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_254.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_254.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_254.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_254.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1,5 @@
-msg_254.c(6): error: syntax error ':' [249]
+msg_254.c(19): error: newline in string or char constant [254]
+msg_254.c(19): error: unterminated string constant [258]
+msg_254.c(19): error: syntax error '"' [249]
+msg_254.c(20): error: newline in string or char constant [254]
+msg_254.c(20): error: unterminated string constant [258]
Index: src/tests/usr.bin/xlint/lint1/msg_262.c
diff -u src/tests/usr.bin/xlint/lint1/msg_262.c:1.2 src/tests/usr.bin/xlint/lint1/msg_262.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_262.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_262.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: msg_262.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_262.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_262.c"
 
-// Test for message: \" inside character constants undefined in traditional C [262]
+/* Test for message: \" inside character constants undefined in traditional C [262] */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -tw */
+
+char msg = '\"';		/* expect: [262] */
Index: src/tests/usr.bin/xlint/lint1/msg_262.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_262.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_262.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_262.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_262.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1 @@
-msg_262.c(6): error: syntax error ':' [249]
+msg_262.c(8): warning: \" inside character constants undefined in traditional C [262]
Index: src/tests/usr.bin/xlint/lint1/msg_263.c
diff -u src/tests/usr.bin/xlint/lint1/msg_263.c:1.2 src/tests/usr.bin/xlint/lint1/msg_263.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_263.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_263.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,8 @@
-/*	$NetBSD: msg_263.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_263.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_263.c"
 
-// Test for message: \? undefined in traditional C [263]
+/* Test for message: \? undefined in traditional C [263] */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -tw */
+
+char ch = '\?';			/* expect: [263] */
Index: src/tests/usr.bin/xlint/lint1/msg_263.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_263.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_263.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_263.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_263.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1 @@
-msg_263.c(6): error: syntax error ':' [249]
+msg_263.c(8): warning: \? undefined in traditional C [263]

Index: src/tests/usr.bin/xlint/lint1/msg_082.c
diff -u src/tests/usr.bin/xlint/lint1/msg_082.c:1.3 src/tests/usr.bin/xlint/lint1/msg_082.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_082.c:1.3	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_082.c	Tue Jun 29 07:17:43 2021
@@ -1,8 +1,8 @@
-/*	$NetBSD: msg_082.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
+/*	$NetBSD: msg_082.c,v 1.4 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_082.c"
 
 /* Test for message: \x undefined in traditional C [82] */
 
 /* lint1-flags: -Stw */
 
-char str[] = "A he\x78 escape";		/* expect: 82 */
+char str[] = "A he\x78 escape";		/* expect: [82] */

Reply via email to