Sat Jan 30 17:56:29 2021 UTC ()
lint: remove message 189, add tests for a few other messages

Message 189 would have applied to traditional C and was supposed to
detect assignments between struct and union types.  The corresponding
check had never been implemented though.

Traditional C has been superseded for 30 years now, therefore there is no
point in adding this check retroactively.


(rillig)
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_189.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_189.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_191.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_191.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_192.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_192.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_193.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_193.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_194.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_194.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_231.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_231.exp
diff -r1.69 -r1.70 src/usr.bin/xlint/lint1/err.c

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_189.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_189.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_189.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,19 @@ @@ -1,7 +1,19 @@
1/* $NetBSD: msg_189.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_189.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_189.c" 2# 3 "msg_189.c"
3 3
4// Test for message: assignment of struct/union illegal in traditional C [189] 4/* Test for message: assignment of struct/union illegal in traditional C [189] */
5 5
6TODO: "Add example code that triggers the above message." 6/* lint1-flags: -tw */
7TODO: "Add example code that almost triggers the above message." 7
 8struct s {
 9 int member;
 10};
 11
 12void
 13example()
 14{
 15 struct s a, b;
 16
 17 a.member = 3;
 18 b = a; /* message 189 is not triggered anymore */
 19}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_189.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_189.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_189.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_191.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_191.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_191.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,14 @@ @@ -1,7 +1,14 @@
1/* $NetBSD: msg_191.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_191.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_191.c" 2# 3 "msg_191.c"
3 3
4// Test for message: %s set but not used in function %s [191] 4// Test for message: %s set but not used in function %s [191]
5 5
6TODO: "Add example code that triggers the above message." 6void
7TODO: "Add example code that almost triggers the above message." 7example(void)
 8{
 9 int local;
 10
 11 local = 3; /* expect: 191 */
 12
 13 local = 5;
 14}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_191.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_191.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_191.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_192.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_192.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_192.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
1/* $NetBSD: msg_192.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_192.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_192.c" 2# 3 "msg_192.c"
3 3
4// Test for message: %s unused in function %s [192] 4// Test for message: %s unused in function %s [192]
5 5
6TODO: "Add example code that triggers the above message." 6void
7TODO: "Add example code that almost triggers the above message." 7example(int param) /* expect: 231 */
 8{
 9 int local; /* expect: 192 */
 10}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_192.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_192.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_192.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_193.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_193.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_193.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
1/* $NetBSD: msg_193.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_193.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_193.c" 2# 3 "msg_193.c"
3 3
4// Test for message: statement not reached [193] 4// Test for message: statement not reached [193]
5 5
6TODO: "Add example code that triggers the above message." 6void example(void)
7TODO: "Add example code that almost triggers the above message." 7{
 8 return;
 9 return; /* expect: 193 */
 10}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_193.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_193.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_193.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_194.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_194.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_194.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,13 @@ @@ -1,7 +1,13 @@
1/* $NetBSD: msg_194.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_194.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_194.c" 2# 3 "msg_194.c"
3 3
4// Test for message: label %s redefined [194] 4// Test for message: label %s redefined [194]
5 5
6TODO: "Add example code that triggers the above message." 6void example(void)
7TODO: "Add example code that almost triggers the above message." 7{
 8 int i = 0;
 9label: /* expect: 232 */
 10 i = 1;
 11label: /* expect: 194 */
 12 i = 2;
 13}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_194.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_194.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_194.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_231.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_231.c 2021/01/02 10:22:44 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_231.c 2021/01/30 17:56:29 1.2
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
1/* $NetBSD: msg_231.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */ 1/* $NetBSD: msg_231.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
2# 3 "msg_231.c" 2# 3 "msg_231.c"
3 3
4// Test for message: argument %s unused in function %s [231] 4// Test for message: argument %s unused in function %s [231]
5 5
6TODO: "Add example code that triggers the above message." 6void
7TODO: "Add example code that almost triggers the above message." 7example(int param) /* expect: 231 */
 8{
 9 int local; /* expect: 192 */
 10}

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/msg_231.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_231.exp 2021/01/02 10:22:44 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_231.exp 2021/01/30 17:56:29 1.2

cvs diff -r1.69 -r1.70 src/usr.bin/xlint/lint1/err.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/err.c 2021/01/17 17:14:34 1.69
+++ src/usr.bin/xlint/lint1/err.c 2021/01/30 17:56:29 1.70
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: err.c,v 1.69 2021/01/17 17:14:34 rillig Exp $ */ 1/* $NetBSD: err.c,v 1.70 2021/01/30 17:56:29 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: err.c,v 1.69 2021/01/17 17:14:34 rillig Exp $"); 40__RCSID("$NetBSD: err.c,v 1.70 2021/01/30 17:56:29 rillig Exp $");
41#endif 41#endif
42 42
43#include <sys/types.h> 43#include <sys/types.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47#include "lint1.h" 47#include "lint1.h"
48 48
49/* number of errors found */ 49/* number of errors found */
50int nerr; 50int nerr;
51 51
52/* number of syntax errors */ 52/* number of syntax errors */
53int sytxerr; 53int sytxerr;
@@ -238,27 +238,27 @@ const char *msgs[] = { @@ -238,27 +238,27 @@ const char *msgs[] = {
238 "invalid initializer type %s", /* 176 */ 238 "invalid initializer type %s", /* 176 */
239 "non-constant initializer", /* 177 */ 239 "non-constant initializer", /* 177 */
240 "initializer does not fit", /* 178 */ 240 "initializer does not fit", /* 178 */
241 "cannot initialize struct/union with no named member", /* 179 */ 241 "cannot initialize struct/union with no named member", /* 179 */
242 "bit-field initializer does not fit", /* 180 */ 242 "bit-field initializer does not fit", /* 180 */
243 "{}-enclosed initializer required", /* 181 */ 243 "{}-enclosed initializer required", /* 181 */
244 "incompatible pointer types (%s != %s)", /* 182 */ 244 "incompatible pointer types (%s != %s)", /* 182 */
245 "illegal combination of %s (%s) and %s (%s)", /* 183 */ 245 "illegal combination of %s (%s) and %s (%s)", /* 183 */
246 "illegal pointer combination", /* 184 */ 246 "illegal pointer combination", /* 184 */
247 "initialisation type mismatch (%s) and (%s)", /* 185 */ 247 "initialisation type mismatch (%s) and (%s)", /* 185 */
248 "bit-field initialisation is illegal in traditional C", /* 186 */ 248 "bit-field initialisation is illegal in traditional C", /* 186 */
249 "non-null byte ignored in string initializer", /* 187 */ 249 "non-null byte ignored in string initializer", /* 187 */
250 "no automatic aggregate initialization in traditional C", /* 188 */ 250 "no automatic aggregate initialization in traditional C", /* 188 */
251 "assignment of struct/union illegal in traditional C", /* 189 */ 251 "", /* no longer used */ /* 189 */
252 "empty array declaration: %s", /* 190 */ 252 "empty array declaration: %s", /* 190 */
253 "%s set but not used in function %s", /* 191 */ 253 "%s set but not used in function %s", /* 191 */
254 "%s unused in function %s", /* 192 */ 254 "%s unused in function %s", /* 192 */
255 "statement not reached", /* 193 */ 255 "statement not reached", /* 193 */
256 "label %s redefined", /* 194 */ 256 "label %s redefined", /* 194 */
257 "case not in switch", /* 195 */ 257 "case not in switch", /* 195 */
258 "case label affected by conversion", /* 196 */ 258 "case label affected by conversion", /* 196 */
259 "non-constant case expression", /* 197 */ 259 "non-constant case expression", /* 197 */
260 "non-integral case expression", /* 198 */ 260 "non-integral case expression", /* 198 */
261 "duplicate case in switch: %ld", /* 199 */ 261 "duplicate case in switch: %ld", /* 199 */
262 "duplicate case in switch: %lu", /* 200 */ 262 "duplicate case in switch: %lu", /* 200 */
263 "default outside switch", /* 201 */ 263 "default outside switch", /* 201 */
264 "duplicate default in switch", /* 202 */ 264 "duplicate default in switch", /* 202 */