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 messages



details:   https://anonhg.NetBSD.org/src/rev/54f52c4b6327
branches:  trunk
changeset: 979711:54f52c4b6327
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 07 18:37:41 2021 +0000

description:
lint: add tests for some messages

diffstat:

 tests/usr.bin/xlint/lint1/msg_006.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_006.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_007.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_007.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_008.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_008.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_009.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_009.exp |   5 ++++-
 tests/usr.bin/xlint/lint1/msg_010.c   |  20 +++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_010.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_011.c   |  23 ++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_011.exp |   7 ++++++-
 tests/usr.bin/xlint/lint1/msg_180.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_180.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_221.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_221.exp |   2 +-
 16 files changed, 88 insertions(+), 32 deletions(-)

diffs (216 lines):

diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_006.c
--- a/tests/usr.bin/xlint/lint1/msg_006.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_006.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_006.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_006.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_006.c"
 
 // Test for message: use 'double' instead of 'long float' [6]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+long float x;
+double x;
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_006.exp
--- a/tests/usr.bin/xlint/lint1/msg_006.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_006.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,2 @@
-msg_006.c(6): syntax error ':' [249]
+msg_006.c(6): warning: use 'double' instead of 'long float' [6]
+msg_006.c(6): illegal type combination [4]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_007.c
--- a/tests/usr.bin/xlint/lint1/msg_007.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_007.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_007.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_007.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_007.c"
 
 // Test for message: only one storage class allowed [7]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern static void example(void);
+extern extern_function(void);
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_007.exp
--- a/tests/usr.bin/xlint/lint1/msg_007.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_007.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,1 @@
-msg_007.c(6): syntax error ':' [249]
+msg_007.c(6): only one storage class allowed [7]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_008.c
--- a/tests/usr.bin/xlint/lint1/msg_008.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_008.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_008.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_008.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_008.c"
 
 // Test for message: illegal storage class [8]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+typedef void
+example(void)
+{
+}
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_008.exp
--- a/tests/usr.bin/xlint/lint1/msg_008.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_008.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,1 @@
-msg_008.c(6): syntax error ':' [249]
+msg_008.c(8): illegal storage class [8]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_009.c
--- a/tests/usr.bin/xlint/lint1/msg_009.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_009.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_009.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_009.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_009.c"
 
 // Test for message: only register valid as formal parameter storage class [9]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern void typedef_example(typedef int param);
+extern void auto_example(auto int param);
+extern void static_example(static int param);
+extern void extern_example(extern int param);
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_009.exp
--- a/tests/usr.bin/xlint/lint1/msg_009.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_009.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,4 @@
-msg_009.c(6): syntax error ':' [249]
+msg_009.c(6): only register valid as formal parameter storage class [9]
+msg_009.c(7): only register valid as formal parameter storage class [9]
+msg_009.c(8): only register valid as formal parameter storage class [9]
+msg_009.c(9): only register valid as formal parameter storage class [9]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_010.c
--- a/tests/usr.bin/xlint/lint1/msg_010.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_010.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,21 @@
-/*     $NetBSD: msg_010.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_010.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_010.c"
 
 // Test for message: duplicate '%s' [10]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+inline inline void
+double_inline(void)
+{
+}
+
+const const int
+double_const(void)
+{
+       return 0;
+}
+
+volatile volatile int
+double_volatile(void)
+{
+       return 0;
+}
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_010.exp
--- a/tests/usr.bin/xlint/lint1/msg_010.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_010.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,3 @@
-msg_010.c(6): syntax error ':' [249]
+msg_010.c(6): warning: duplicate 'inline' [10]
+msg_010.c(11): warning: duplicate 'const' [10]
+msg_010.c(17): warning: duplicate 'volatile' [10]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_011.c
--- a/tests/usr.bin/xlint/lint1/msg_011.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_011.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,24 @@
-/*     $NetBSD: msg_011.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_011.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_011.c"
 
 // Test for message: bit-field initializer out of range [11]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct example {
+       int bit_field: 4;
+} example_var[] = {
+    { 2 },
+    { 1 + 1 },
+    { 1ULL << 40 },
+    { 1LL << 40 },
+    { -16 - 1 },
+};
+
+struct example_u {
+       unsigned int bit_field: 4;
+} example_var_u[] = {
+    { 2 },
+    { 1 + 1 },
+    { 1ULL << 40 },
+    { 1LL << 40 },
+    { -16 - 1 },
+};
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_011.exp
--- a/tests/usr.bin/xlint/lint1/msg_011.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_011.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,6 @@
-msg_011.c(6): syntax error ':' [249]
+msg_011.c(11): warning: bit-field initializer does not fit [180]
+msg_011.c(12): warning: bit-field initializer does not fit [180]
+msg_011.c(13): warning: bit-field initializer does not fit [180]
+msg_011.c(21): warning: bit-field initializer does not fit [180]
+msg_011.c(22): warning: bit-field initializer does not fit [180]
+msg_011.c(23): warning: initialisation of unsigned with negative constant [221]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_180.c
--- a/tests/usr.bin/xlint/lint1/msg_180.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_180.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_180.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_180.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_180.c"
 
 // Test for message: bit-field initializer does not fit [180]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct example {
+       unsigned int a: 5;
+       unsigned int b: 5;
+} example_var = {
+    32,
+    31
+};
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_180.exp
--- a/tests/usr.bin/xlint/lint1/msg_180.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_180.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,1 @@
-msg_180.c(6): syntax error ':' [249]
+msg_180.c(10): warning: bit-field initializer does not fit [180]
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_221.c
--- a/tests/usr.bin/xlint/lint1/msg_221.c       Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_221.c       Thu Jan 07 18:37:41 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_221.c,v 1.1 2021/01/02 10:22:44 rillig Exp $       */
+/*     $NetBSD: msg_221.c,v 1.2 2021/01/07 18:37:41 rillig Exp $       */
 # 3 "msg_221.c"
 
 // Test for message: initialisation of unsigned with negative constant [221]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+struct example {
+       unsigned int a: 5;
+       unsigned int b: 5;
+} example_var = {
+    -1,
+    31
+};
diff -r a221d672230a -r 54f52c4b6327 tests/usr.bin/xlint/lint1/msg_221.exp
--- a/tests/usr.bin/xlint/lint1/msg_221.exp     Thu Jan 07 18:11:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_221.exp     Thu Jan 07 18:37:41 2021 +0000
@@ -1,1 +1,1 @@
-msg_221.c(6): syntax error ':' [249]
+msg_221.c(10): warning: initialisation of unsigned with negative constant [221]



Home | Main Index | Thread Index | Old Index