Module Name:    src
Committed By:   rillig
Date:           Fri Aug 11 04:27:49 UTC 2023

Modified Files:
        src/tests/usr.bin/xlint/lint1: check-expect.lua msg_255.c

Log Message:
tests/lint: test parsing of preprocessing directives


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/check-expect.lua
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_255.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/check-expect.lua
diff -u src/tests/usr.bin/xlint/lint1/check-expect.lua:1.7 src/tests/usr.bin/xlint/lint1/check-expect.lua:1.8
--- src/tests/usr.bin/xlint/lint1/check-expect.lua:1.7	Sat Jul  8 11:03:00 2023
+++ src/tests/usr.bin/xlint/lint1/check-expect.lua	Fri Aug 11 04:27:49 2023
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.7 2023/07/08 11:03:00 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.8 2023/08/11 04:27:49 rillig Exp $
 
 --[[
 
@@ -62,7 +62,7 @@ end
 --
 -- example return values:
 --   {
---     ["file.c(18)"] = {"invalid argument 'a'", "invalid argument 'b'"},
+--     ["file.c(18)"] = {"syntax error 'a' [249]", "syntax error 'b' [249]"},
 --     ["file.c(23)"] = {"not a constant expression [123]"},
 --   },
 --   { "file.c(18)", "file.c(23)" }
@@ -132,7 +132,7 @@ local function load_exp(exp_fname)
 
   local messages = {}
   for exp_lineno, line in ipairs(lines) do
-    for location, message in line:gmatch("(%S+%(%d+%)): (.+)$") do
+    for location, message in line:gmatch("(.+%(%d+%)): (.+)$") do
       table.insert(messages, {
         exp_lineno = exp_lineno,
         location = location,

Index: src/tests/usr.bin/xlint/lint1/msg_255.c
diff -u src/tests/usr.bin/xlint/lint1/msg_255.c:1.5 src/tests/usr.bin/xlint/lint1/msg_255.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_255.c:1.5	Sun Jul  9 11:01:27 2023
+++ src/tests/usr.bin/xlint/lint1/msg_255.c	Fri Aug 11 04:27:49 2023
@@ -1,13 +1,45 @@
-/*	$NetBSD: msg_255.c,v 1.5 2023/07/09 11:01:27 rillig Exp $	*/
+/*	$NetBSD: msg_255.c,v 1.6 2023/08/11 04:27:49 rillig Exp $	*/
 # 3 "msg_255.c"
 
 // Test for message: undefined or invalid '#' directive [255]
 
 /* lint1-extra-flags: -X 351 */
 
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+#
+
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+#pragma
+
 #pragma once
 
 /* expect+1: warning: undefined or invalid '#' directive [255] */
 #fatal_error
 
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+#    ident "obsolete"
+
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+#1
+
+// Sets the line number of the current file.
+# 2
+
+// Switch back to the main file.
+# 30 "msg_255.c"
+
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+# 3/
+
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+# 4 /
+
+/* expect+1: warning: undefined or invalid '#' directive [255] */
+# 5 "unfinished
+
+// An empty string means standard input; tabs may be used for spacing.
+#	6	""
+
+# 44 "msg_255.c"
+
 int dummy;

Reply via email to