Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: demonstrate that -t mode is ...



details:   https://anonhg.NetBSD.org/src/rev/0338f9ecd925
branches:  trunk
changeset: 958369:0338f9ecd925
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 02 11:12:34 2021 +0000

description:
lint: demonstrate that -t mode is practically unusable

Since main1.c from 2014-04-18, running lint in -t mode produces strange
warnings in lines 1 to 3 of no file at all.

This is caused by the builtins that are parsed in main().  These
builtins are incompatible with traditional mode because they use long
double, which had not been known at that time.

diffstat:

 tests/usr.bin/xlint/lint1/msg_219.c        |  13 +++++++++----
 tests/usr.bin/xlint/lint1/msg_219.exp      |  11 ++++++++++-
 tests/usr.bin/xlint/lint1/t_integration.sh |  10 ++++++----
 3 files changed, 25 insertions(+), 9 deletions(-)

diffs (67 lines):

diff -r d1b43f63e828 -r 0338f9ecd925 tests/usr.bin/xlint/lint1/msg_219.c
--- a/tests/usr.bin/xlint/lint1/msg_219.c       Sat Jan 02 10:22:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_219.c       Sat Jan 02 11:12:34 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_219.c,v 1.1 2021/01/02 10:22:44 rillig Exp $       */
+/*     $NetBSD: msg_219.c,v 1.2 2021/01/02 11:12:34 rillig Exp $       */
 # 3 "msg_219.c"
 
-// Test for message: concatenated strings are illegal in traditional C [219]
+
+/* Test for message: concatenated strings are illegal in traditional C [219] */
+
+/* lint1-flags: -t -w */
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+char concat1[] = "one";
+char concat2[] = "one" "two";
+char concat3[] = "one" "two" "three";
+char concat4[] = "one" "two" "three" "four";
diff -r d1b43f63e828 -r 0338f9ecd925 tests/usr.bin/xlint/lint1/msg_219.exp
--- a/tests/usr.bin/xlint/lint1/msg_219.exp     Sat Jan 02 10:22:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_219.exp     Sat Jan 02 11:12:34 2021 +0000
@@ -1,1 +1,10 @@
-msg_219.c(6): syntax error ':' [249]
+(1): warning: 'long double' is illegal in traditional C [266]
+(1): warning: function prototypes are illegal in traditional C [270]
+(2): warning: 'long double' is illegal in traditional C [266]
+(2): warning: function prototypes are illegal in traditional C [270]
+(3): warning: 'long double' is illegal in traditional C [266]
+(3): warning: 'long double' is illegal in traditional C [266]
+(3): warning: function prototypes are illegal in traditional C [270]
+msg_219.c(10): warning: concatenated strings are illegal in traditional C [219]
+msg_219.c(11): warning: concatenated strings are illegal in traditional C [219]
+msg_219.c(12): warning: concatenated strings are illegal in traditional C [219]
diff -r d1b43f63e828 -r 0338f9ecd925 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sat Jan 02 10:22:42 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sat Jan 02 11:12:34 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.18 2021/01/02 10:22:44 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.19 2021/01/02 11:12:34 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -147,17 +147,19 @@
 
 test_case all_messages
 all_messages_body() {
-       local srcdir status msg base
+       local srcdir status msg base flags
 
        srcdir="$(atf_get_srcdir)"
        status="0"
 
        for msg in $(seq 0 329); do
                base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
+               flags="$(sed -n 's,^/\* lint1-flags: \(.*\) \*/$,\1,p' "${base}.c")"
+               flags="${flags:--g -S -w}"
 
-               # shellcheck disable=SC2154
+               # shellcheck disable=SC2154 disable=SC2086
                ${Atf_Check} -s not-exit:0 -o "file:${base}.exp" -e empty \
-                   ${LINT1} -g -S -w "${base}.c" /dev/null \
+                   ${LINT1} ${flags} "${base}.c" /dev/null \
                || status="1"
        done
        return "${status}"



Home | Main Index | Thread Index | Old Index