Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: remove message 189, add tests for ...



details:   https://anonhg.NetBSD.org/src/rev/844d374bd362
branches:  trunk
changeset: 980274:844d374bd362
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 30 17:56:29 2021 +0000

description:
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.

diffstat:

 tests/usr.bin/xlint/lint1/msg_189.c   |  20 ++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_189.exp |   8 +++++++-
 tests/usr.bin/xlint/lint1/msg_191.c   |  13 ++++++++++---
 tests/usr.bin/xlint/lint1/msg_191.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_192.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_192.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_193.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_193.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_194.c   |  12 +++++++++---
 tests/usr.bin/xlint/lint1/msg_194.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_231.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_231.exp |   3 ++-
 usr.bin/xlint/lint1/err.c             |   6 +++---
 13 files changed, 71 insertions(+), 28 deletions(-)

diffs (191 lines):

diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_189.c
--- a/tests/usr.bin/xlint/lint1/msg_189.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_189.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,19 @@
-/*     $NetBSD: msg_189.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_189.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_189.c"
 
-// Test for message: assignment of struct/union illegal in traditional C [189]
+/* Test for message: assignment of struct/union illegal in traditional C [189] */
+
+/* lint1-flags: -tw */
+
+struct s {
+       int member;
+};
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example()
+{
+       struct s a, b;
+
+       a.member = 3;
+       b = a;                  /* message 189 is not triggered anymore */
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_189.exp
--- a/tests/usr.bin/xlint/lint1/msg_189.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_189.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,7 @@
-msg_189.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]
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_191.c
--- a/tests/usr.bin/xlint/lint1/msg_191.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_191.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,14 @@
-/*     $NetBSD: msg_191.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_191.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_191.c"
 
 // Test for message: %s set but not used in function %s [191]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(void)
+{
+       int local;
+
+       local = 3;              /* expect: 191 */
+
+       local = 5;
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_191.exp
--- a/tests/usr.bin/xlint/lint1/msg_191.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_191.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,1 @@
-msg_191.c(6): syntax error ':' [249]
+msg_191.c(11): warning: local set but not used in function example [191]
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_192.c
--- a/tests/usr.bin/xlint/lint1/msg_192.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_192.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,10 @@
-/*     $NetBSD: msg_192.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_192.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_192.c"
 
 // Test for message: %s unused in function %s [192]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(int param)             /* expect: 231 */
+{
+       int local;              /* expect: 192 */
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_192.exp
--- a/tests/usr.bin/xlint/lint1/msg_192.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_192.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_192.c(6): syntax error ':' [249]
+msg_192.c(9): warning: local unused in function example [192]
+msg_192.c(7): warning: argument param unused in function example [231]
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,10 @@
-/*     $NetBSD: msg_193.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_193.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_193.c"
 
 // Test for message: statement not reached [193]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void example(void)
+{
+       return;
+       return;                 /* expect: 193 */
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,1 @@
-msg_193.c(6): syntax error ':' [249]
+msg_193.c(9): warning: statement not reached [193]
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_194.c
--- a/tests/usr.bin/xlint/lint1/msg_194.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_194.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_194.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_194.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_194.c"
 
 // Test for message: label %s redefined [194]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void example(void)
+{
+       int i = 0;
+label:                         /* expect: 232 */
+       i = 1;
+label:                         /* expect: 194 */
+       i = 2;
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_194.exp
--- a/tests/usr.bin/xlint/lint1/msg_194.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_194.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_194.c(6): syntax error ':' [249]
+msg_194.c(11): label label redefined [194]
+msg_194.c(9): warning: label label unused in function example [232]
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_231.c
--- a/tests/usr.bin/xlint/lint1/msg_231.c       Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_231.c       Sat Jan 30 17:56:29 2021 +0000
@@ -1,7 +1,10 @@
-/*     $NetBSD: msg_231.c,v 1.1 2021/01/02 10:22:44 rillig Exp $       */
+/*     $NetBSD: msg_231.c,v 1.2 2021/01/30 17:56:29 rillig Exp $       */
 # 3 "msg_231.c"
 
 // Test for message: argument %s unused in function %s [231]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(int param)             /* expect: 231 */
+{
+       int local;              /* expect: 192 */
+}
diff -r d8eb7557890f -r 844d374bd362 tests/usr.bin/xlint/lint1/msg_231.exp
--- a/tests/usr.bin/xlint/lint1/msg_231.exp     Sat Jan 30 17:38:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_231.exp     Sat Jan 30 17:56:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_231.c(6): syntax error ':' [249]
+msg_231.c(9): warning: local unused in function example [192]
+msg_231.c(7): warning: argument param unused in function example [231]
diff -r d8eb7557890f -r 844d374bd362 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sat Jan 30 17:38:57 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sat Jan 30 17:56:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.69 2021/01/17 17:14:34 rillig Exp $  */
+/*     $NetBSD: err.c,v 1.70 2021/01/30 17:56:29 rillig Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.69 2021/01/17 17:14:34 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.70 2021/01/30 17:56:29 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -248,7 +248,7 @@
        "bit-field initialisation is illegal in traditional C",       /* 186 */
        "non-null byte ignored in string initializer",                /* 187 */
        "no automatic aggregate initialization in traditional C",     /* 188 */
-       "assignment of struct/union illegal in traditional C",        /* 189 */
+       "",                     /* no longer used */                  /* 189 */
        "empty array declaration: %s",                                /* 190 */
        "%s set but not used in function %s",                         /* 191 */
        "%s unused in function %s",                                   /* 192 */



Home | Main Index | Thread Index | Old Index