Sat Jan 2 18:06:01 2021 UTC ()
lint: add a few more tests

No serious bugs found this time.


(rillig)
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_000.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_000.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_001.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_001.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_002.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_002.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_004.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_004.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_005.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_005.exp
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_085.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_085.exp
diff -r1.100 -r1.101 src/usr.bin/xlint/lint1/decl.c

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

--- src/tests/usr.bin/xlint/lint1/msg_000.c 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_000.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
1/* $NetBSD: msg_000.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */ 1/* $NetBSD: msg_000.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_000.c" 2# 3 "msg_000.c"
3 3
4// Test for message: empty declaration [0] 4// Test for message: empty declaration [0]
5 5
6TODO: "Add example code that triggers the above message." 6extern int extern_declared;
7TODO: "Add example code that almost triggers the above message." 7
 8;
 9
 10static int local_defined;

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_000.exp 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_000.exp 2021/01/02 18:06:01 1.2

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

--- src/tests/usr.bin/xlint/lint1/msg_001.c 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_001.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
1/* $NetBSD: msg_001.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */ 1/* $NetBSD: msg_001.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_001.c" 2# 3 "msg_001.c"
3 3
4// Test for message: old style declaration; add int [1] 4// Test for message: old style declaration; add int [1]
5 5
6TODO: "Add example code that triggers the above message." 6old_style = 1;
7TODO: "Add example code that almost triggers the above message." 7
 8int new_style = 1;

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_001.exp 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_001.exp 2021/01/02 18:06:01 1.2

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

--- src/tests/usr.bin/xlint/lint1/msg_002.c 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_002.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
1/* $NetBSD: msg_002.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */ 1/* $NetBSD: msg_002.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_002.c" 2# 3 "msg_002.c"
3 3
4// Test for message: empty declaration [2] 4// Test for message: empty declaration [2]
5 5
6TODO: "Add example code that triggers the above message." 6int;
7TODO: "Add example code that almost triggers the above message." 7
 8int local_variable;

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_002.exp 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_002.exp 2021/01/02 18:06:01 1.2

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

--- src/tests/usr.bin/xlint/lint1/msg_004.c 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_004.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,21 @@ @@ -1,7 +1,21 @@
1/* $NetBSD: msg_004.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */ 1/* $NetBSD: msg_004.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_004.c" 2# 3 "msg_004.c"
3 3
4// Test for message: illegal type combination [4] 4// Test for message: illegal type combination [4]
5 5
6TODO: "Add example code that triggers the above message." 6// XXX: this goes undetected
7TODO: "Add example code that almost triggers the above message." 7signed double signed_double;
 8
 9int ok_int;
 10double ok_double;
 11float _Complex ok_float_complex;
 12
 13int _Complex illegal_int_complex;
 14
 15char enum {
 16 CHAR
 17};
 18
 19long struct {
 20 int member;
 21};

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_004.exp 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_004.exp 2021/01/02 18:06:01 1.2

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

--- src/tests/usr.bin/xlint/lint1/msg_005.c 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_005.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
1/* $NetBSD: msg_005.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */ 1/* $NetBSD: msg_005.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_005.c" 2# 3 "msg_005.c"
3 3
4// Test for message: modifying typedef with '%s'; only qualifiers allowed [5] 4// Test for message: modifying typedef with '%s'; only qualifiers allowed [5]
5 5
6TODO: "Add example code that triggers the above message." 6typedef int number;
7TODO: "Add example code that almost triggers the above message." 7number long long_variable;
 8number const const_variable;

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_005.exp 2021/01/02 10:22:42 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_005.exp 2021/01/02 18:06:01 1.2

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

--- src/tests/usr.bin/xlint/lint1/msg_085.c 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_085.c 2021/01/02 18:06:01 1.2
@@ -1,7 +1,9 @@ @@ -1,7 +1,9 @@
1/* $NetBSD: msg_085.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ 1/* $NetBSD: msg_085.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
2# 3 "msg_085.c" 2# 3 "msg_085.c"
3 3
4// Test for message: dubious tag declaration: %s %s [85] 4// Test for message: dubious tag declaration: %s %s [85]
5 5
6TODO: "Add example code that triggers the above message." 6extern int stat(struct stat *);
7TODO: "Add example code that almost triggers the above message." 7
 8struct ok;
 9extern int ok(struct ok *);

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

--- src/tests/usr.bin/xlint/lint1/Attic/msg_085.exp 2021/01/02 10:22:43 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_085.exp 2021/01/02 18:06:01 1.2

cvs diff -r1.100 -r1.101 src/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/decl.c 2021/01/02 17:17:00 1.100
+++ src/usr.bin/xlint/lint1/decl.c 2021/01/02 18:06:01 1.101
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.100 2021/01/02 17:17:00 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.101 2021/01/02 18:06:01 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: decl.c,v 1.100 2021/01/02 17:17:00 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.101 2021/01/02 18:06:01 rillig Exp $");
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50 50
51const char *unnamed = "<unnamed>"; 51const char *unnamed = "<unnamed>";
52 52
53/* shared type structures for arithmtic types and void */ 53/* shared type structures for arithmtic types and void */
54static type_t *typetab; 54static type_t *typetab;
@@ -377,36 +377,36 @@ add_type(type_t *tp) @@ -377,36 +377,36 @@ add_type(type_t *tp)
377static type_t * 377static type_t *
378tdeferr(type_t *td, tspec_t t) 378tdeferr(type_t *td, tspec_t t)
379{ 379{
380 tspec_t t2; 380 tspec_t t2;
381 381
382 t2 = td->t_tspec; 382 t2 = td->t_tspec;
383 383
384 switch (t) { 384 switch (t) {
385 case SIGNED: 385 case SIGNED:
386 case UNSIGN: 386 case UNSIGN:
387 if (t2 == CHAR || t2 == SHORT || t2 == INT || t2 == LONG || 387 if (t2 == CHAR || t2 == SHORT || t2 == INT || t2 == LONG ||
388 t2 == QUAD) { 388 t2 == QUAD) {
389 if (!tflag) 389 if (!tflag)
390 /* modifying typedef with ... */ 390 /* modifying typedef with '%s'; only ... */
391 warning(5, ttab[t].tt_name); 391 warning(5, ttab[t].tt_name);
392 td = duptyp(gettyp(merge_type_specifiers(t2, t))); 392 td = duptyp(gettyp(merge_type_specifiers(t2, t)));
393 td->t_typedef = 1; 393 td->t_typedef = 1;
394 return td; 394 return td;
395 } 395 }
396 break; 396 break;
397 case SHORT: 397 case SHORT:
398 if (t2 == INT || t2 == UINT) { 398 if (t2 == INT || t2 == UINT) {
399 /* modifying typedef with ... */ 399 /* modifying typedef with '%s'; only qualifiers ... */
400 warning(5, "short"); 400 warning(5, "short");
401 td = duptyp(gettyp(t2 == INT ? SHORT : USHORT)); 401 td = duptyp(gettyp(t2 == INT ? SHORT : USHORT));
402 td->t_typedef = 1; 402 td->t_typedef = 1;
403 return td; 403 return td;
404 } 404 }
405 break; 405 break;
406 case LONG: 406 case LONG:
407 if (t2 == INT || t2 == UINT || t2 == LONG || t2 == ULONG || 407 if (t2 == INT || t2 == UINT || t2 == LONG || t2 == ULONG ||
408 t2 == FLOAT || t2 == DOUBLE || t2 == DCOMPLEX) { 408 t2 == FLOAT || t2 == DOUBLE || t2 == DCOMPLEX) {
409 /* modifying typedef with ... */ 409 /* modifying typedef with ... */
410 warning(5, "long"); 410 warning(5, "long");
411 if (t2 == INT) { 411 if (t2 == INT) {
412 td = gettyp(LONG); 412 td = gettyp(LONG);