tests/lint: test parsing of preprocessing directives

This commit is contained in:
rillig 2023-08-11 04:27:49 +00:00
parent 67110fc12f
commit fdd1c40690
2 changed files with 36 additions and 4 deletions

View File

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

View File

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