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: add tests for some of the me...



details:   https://anonhg.NetBSD.org/src/rev/7e049cdbad42
branches:  trunk
changeset: 1017650:7e049cdbad42
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 03 15:35:00 2021 +0000

description:
lint: add tests for some of the messages

diffstat:

 tests/usr.bin/xlint/lint1/msg_027.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_027.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_029.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/msg_029.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_031.c   |  14 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_031.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_034.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/msg_034.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_036.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_036.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_037.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_037.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_071.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/msg_071.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_072.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_072.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_073.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_073.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_074.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_074.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_086.c   |  21 ++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_086.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_087.c   |  14 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_087.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_088.c   |  13 ++++++++++---
 tests/usr.bin/xlint/lint1/msg_088.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_230.c   |  25 ++++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_230.exp |   4 +++-
 28 files changed, 141 insertions(+), 56 deletions(-)

diffs (truncated from 365 to 300 lines):

diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_027.c
--- a/tests/usr.bin/xlint/lint1/msg_027.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_027.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_027.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_027.c"
 
 // Test for message: redeclaration of %s [27]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern int identifier(void);
+
+extern double identifier(void);
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_027.exp
--- a/tests/usr.bin/xlint/lint1/msg_027.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_027.c(6): syntax error ':' [249]
+msg_027.c(8): redeclaration of identifier [27]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_029.c
--- a/tests/usr.bin/xlint/lint1/msg_029.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_029.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,11 @@
-/*     $NetBSD: msg_029.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_029.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_029.c"
 
 // Test for message: previously declared extern, becomes static: %s [29]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern int function(void);
+
+static int function(void)
+{
+       return function();
+}
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_029.exp
--- a/tests/usr.bin/xlint/lint1/msg_029.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_029.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_029.c(6): syntax error ':' [249]
+msg_029.c(9): warning: previously declared extern, becomes static: function [29]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_031.c
--- a/tests/usr.bin/xlint/lint1/msg_031.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_031.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: msg_031.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_031.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_031.c"
 
 // Test for message: incomplete structure or union %s: %s [31]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct complete {
+       int dummy;
+};
+
+struct incomplete;
+
+
+struct complete complete_var;
+
+struct incomplete incomplete_var;
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_031.exp
--- a/tests/usr.bin/xlint/lint1/msg_031.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_031.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,2 @@
-msg_031.c(6): syntax error ':' [249]
+msg_031.c(10): warning: struct incomplete never defined [233]
+msg_031.c(15): incomplete structure or union incomplete: incomplete_var [31]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_034.c
--- a/tests/usr.bin/xlint/lint1/msg_034.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_034.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,11 @@
-/*     $NetBSD: msg_034.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_034.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_034.c"
 
 // Test for message: nonportable bit-field type [34]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -S -g -p -w */
+
+struct example {
+       int nonportable: 1;
+       unsigned int portable: 1;
+};
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_034.exp
--- a/tests/usr.bin/xlint/lint1/msg_034.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_034.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_034.c(6): syntax error ':' [249]
+msg_034.c(9): warning: nonportable bit-field type [34]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_036.c
--- a/tests/usr.bin/xlint/lint1/msg_036.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_036.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,10 @@
-/*     $NetBSD: msg_036.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_036.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_036.c"
 
 // Test for message: illegal bit-field size: %d [36]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct example {
+       unsigned int too_large: 100000;
+       unsigned int negative: -1;
+       unsigned int ok: 3;
+};
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_036.exp
--- a/tests/usr.bin/xlint/lint1/msg_036.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_036.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,2 @@
-msg_036.c(6): syntax error ':' [249]
+msg_036.c(7): illegal bit-field size: 160 [36]
+msg_036.c(8): illegal bit-field size: 255 [36]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_037.c
--- a/tests/usr.bin/xlint/lint1/msg_037.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_037.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_037.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_037.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_037.c"
 
 // Test for message: zero size bit-field [37]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct example {
+       unsigned int zero: 0;
+       unsigned int ok: 3;
+};
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_037.exp
--- a/tests/usr.bin/xlint/lint1/msg_037.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_037.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_037.c(6): syntax error ':' [249]
+msg_037.c(7): zero size bit-field [37]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_071.c
--- a/tests/usr.bin/xlint/lint1/msg_071.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_071.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,11 @@
-/*     $NetBSD: msg_071.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_071.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_071.c"
 
 // Test for message: too many characters in character constant [71]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/*
+ * C11 6.4.4.4p7 says: Each hexadecimal escape sequence is the longest
+ * sequence of characters that can constitute the escape sequence.
+ */
+char valid_multi_digit_hex = '\x0000000000000000000000a';
+char invalid_multi_digit_hex = '\x000g000000000000000000a';
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_071.exp
--- a/tests/usr.bin/xlint/lint1/msg_071.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_071.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,2 @@
-msg_071.c(6): syntax error ':' [249]
+msg_071.c(11): too many characters in character constant [71]
+msg_071.c(11): warning: initializer does not fit [178]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_072.c
--- a/tests/usr.bin/xlint/lint1/msg_072.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_072.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_072.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_072.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_072.c"
 
 // Test for message: typedef declares no type name [72]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+typedef int;
+
+typedef int number;
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_072.exp
--- a/tests/usr.bin/xlint/lint1/msg_072.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_072.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_072.c(6): syntax error ':' [249]
+msg_072.c(6): warning: typedef declares no type name [72]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_073.c
--- a/tests/usr.bin/xlint/lint1/msg_073.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_073.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_073.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_073.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_073.c"
 
 // Test for message: empty character constant [73]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+char empty = '';
+char letter = 'x';
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_073.exp
--- a/tests/usr.bin/xlint/lint1/msg_073.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_073.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_073.c(6): syntax error ':' [249]
+msg_073.c(6): empty character constant [73]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_074.c
--- a/tests/usr.bin/xlint/lint1/msg_074.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_074.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_074.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_074.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_074.c"
 
 // Test for message: no hex digits follow \x [74]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+char invalid_hex = '\x';
+char invalid_hex_letter = '\xg';
+char valid_hex = '\xff';
+char valid_single_digit_hex = '\xa';
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_074.exp
--- a/tests/usr.bin/xlint/lint1/msg_074.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_074.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,3 @@
-msg_074.c(6): syntax error ':' [249]
+msg_074.c(6): no hex digits follow \x [74]
+msg_074.c(7): no hex digits follow \x [74]
+msg_074.c(7): warning: multi-character character constant [294]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_086.c
--- a/tests/usr.bin/xlint/lint1/msg_086.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_086.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,22 @@
-/*     $NetBSD: msg_086.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_086.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_086.c"
 
 // Test for message: automatic hides external declaration: %s [86]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -S -g -h -w */
+
+extern int identifier;
+
+int
+local_auto(void)
+{
+       int identifier = 3;
+       return identifier;
+}
+
+/* XXX: the function argument does not trigger the warning. */
+int
+arg_auto(int identifier)
+{
+       return identifier;
+}
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_086.exp
--- a/tests/usr.bin/xlint/lint1/msg_086.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_086.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_086.c(6): syntax error ':' [249]
+msg_086.c(13): warning: automatic hides external declaration: identifier [86]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_087.c
--- a/tests/usr.bin/xlint/lint1/msg_087.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_087.c       Sun Jan 03 15:35:00 2021 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: msg_087.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_087.c,v 1.2 2021/01/03 15:35:00 rillig Exp $       */
 # 3 "msg_087.c"
 
 // Test for message: static hides external declaration: %s [87]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -g -h -S -w */
+
+extern int counter;
+
+int
+count(void)
+{
+       static int counter;
+       return counter++;
+}
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_087.exp
--- a/tests/usr.bin/xlint/lint1/msg_087.exp     Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_087.exp     Sun Jan 03 15:35:00 2021 +0000
@@ -1,1 +1,1 @@
-msg_087.c(6): syntax error ':' [249]
+msg_087.c(13): warning: static hides external declaration: counter [87]
diff -r 89f0ac2bedff -r 7e049cdbad42 tests/usr.bin/xlint/lint1/msg_088.c
--- a/tests/usr.bin/xlint/lint1/msg_088.c       Sun Jan 03 15:33:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_088.c       Sun Jan 03 15:35:00 2021 +0000



Home | Main Index | Thread Index | Old Index