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 messages 93, 9...



details:   https://anonhg.NetBSD.org/src/rev/f68490d9f9f6
branches:  trunk
changeset: 949266:f68490d9f9f6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 07 00:38:46 2021 +0000

description:
lint: add tests for messages 93, 94, 95, 96, 97, 98, 99

diffstat:

 tests/usr.bin/xlint/lint1/msg_093.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_093.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_094.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_094.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_095.c   |  18 +++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_095.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_096.c   |  21 ++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_096.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_097.c   |  22 ++++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_097.exp |  12 +++++++++++-
 tests/usr.bin/xlint/lint1/msg_098.c   |  21 +++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_098.exp |  14 +++++++++++++-
 tests/usr.bin/xlint/lint1/msg_099.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/msg_099.exp |   2 +-
 14 files changed, 123 insertions(+), 30 deletions(-)

diffs (235 lines):

diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_093.c
--- a/tests/usr.bin/xlint/lint1/msg_093.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_093.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_093.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_093.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_093.c"
 
 // Test for message: dubious static function at block level: %s [93]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(void)
+{
+       static void nested(void);
+
+       nested();
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_093.exp
--- a/tests/usr.bin/xlint/lint1/msg_093.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_093.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,1 @@
-msg_093.c(6): syntax error ':' [249]
+msg_093.c(9): warning: dubious static function at block level: nested [93]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_094.c
--- a/tests/usr.bin/xlint/lint1/msg_094.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_094.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_094.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_094.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_094.c"
 
 // Test for message: function has illegal storage class: %s [94]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+register int
+global_example(int arg)
+{
+       register int register_example(int);
+
+       return arg;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_094.exp
--- a/tests/usr.bin/xlint/lint1/msg_094.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_094.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,2 @@
-msg_094.c(6): syntax error ':' [249]
+msg_094.c(7): illegal storage class [8]
+msg_094.c(9): function has illegal storage class: register_example [94]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_095.c
--- a/tests/usr.bin/xlint/lint1/msg_095.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_095.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,19 @@
-/*     $NetBSD: msg_095.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_095.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_095.c"
 
 // Test for message: declaration hides earlier one: %s [95]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -ghSw */
+
+int identifier;
+
+int
+example(int identifier)
+{
+
+       {
+               int identifier = 3;
+       }
+
+       return identifier;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_095.exp
--- a/tests/usr.bin/xlint/lint1/msg_095.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_095.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,1 @@
-msg_095.c(6): syntax error ':' [249]
+msg_095.c(15): warning: declaration hides earlier one: identifier [95]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_096.c
--- a/tests/usr.bin/xlint/lint1/msg_096.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_096.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,22 @@
-/*     $NetBSD: msg_096.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_096.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_096.c"
 
 // Test for message: cannot dereference non-pointer type [96]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+int
+unary_plus(int i)
+{
+       return +i;
+}
+
+int
+unary_minus(int i)
+{
+       return -i;
+}
+
+int
+unary_asterisk(int i)
+{
+       return *i;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_096.exp
--- a/tests/usr.bin/xlint/lint1/msg_096.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_096.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,3 @@
-msg_096.c(6): syntax error ':' [249]
+msg_096.c(21): cannot dereference non-pointer type [96]
+msg_096.c(21): warning: function unary_asterisk expects to return value [214]
+msg_096.c(19): warning: argument i unused in function unary_asterisk [231]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_097.c
--- a/tests/usr.bin/xlint/lint1/msg_097.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_097.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,21 @@
-/*     $NetBSD: msg_097.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_097.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_097.c"
 
-// Test for message: suffix U is illegal in traditional C [97]
+/* Test for message: suffix U is illegal in traditional C [97] */
+
+/* lint1-flags: -gtw */
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example()
+{
+       int i = 1234567;
+       unsigned u = 1234567;
+       unsigned u_upper = 1234567U;
+       unsigned u_lower = 1234567u;
+
+       long l = 1234567L;
+       unsigned long ul = 1234567UL;
+
+       long long ll = 1234567LL;
+       unsigned long long ull = 1234567ULL;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_097.exp
--- a/tests/usr.bin/xlint/lint1/msg_097.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_097.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,11 @@
-msg_097.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]
+msg_097.c(13): warning: suffix U is illegal in traditional C [97]
+msg_097.c(14): warning: suffix U is illegal in traditional C [97]
+msg_097.c(17): warning: suffix U is illegal in traditional C [97]
+msg_097.c(20): warning: suffix U is illegal in traditional C [97]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_098.c
--- a/tests/usr.bin/xlint/lint1/msg_098.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_098.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,20 @@
-/*     $NetBSD: msg_098.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_098.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_098.c"
 
-// Test for message: suffixes F and L are illegal in traditional C [98]
+/* Test for message: suffixes F and L are illegal in traditional C [98] */
+
+/* lint1-flags: -gtw */
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example()
+{
+       float f = 1234.5;
+       float f_F = 1234.5F;
+       float f_f = 1234.5F;
+
+       double d = 1234.5;
+       double d_U = 1234.5U;
+
+       long double ld = 1234.5;
+       long double ld_L = 1234.5L;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_098.exp
--- a/tests/usr.bin/xlint/lint1/msg_098.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_098.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,13 @@
-msg_098.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]
+msg_098.c(12): warning: suffixes F and L are illegal in traditional C [98]
+msg_098.c(13): warning: suffixes F and L are illegal in traditional C [98]
+msg_098.c(16): syntax error 'U' [249]
+msg_098.c(18): warning: 'long double' is illegal in traditional C [266]
+msg_098.c(19): warning: 'long double' is illegal in traditional C [266]
+msg_098.c(19): warning: suffixes F and L are illegal in traditional C [98]
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_099.c
--- a/tests/usr.bin/xlint/lint1/msg_099.c       Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_099.c       Thu Jan 07 00:38:46 2021 +0000
@@ -1,7 +1,11 @@
-/*     $NetBSD: msg_099.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_099.c,v 1.2 2021/01/07 00:38:46 rillig Exp $       */
 # 3 "msg_099.c"
 
 // Test for message: %s undefined [99]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(int defined_variable)
+{
+       int ok = defined_variable;
+       int error = undefined_variable;
+}
diff -r e261243b3c13 -r f68490d9f9f6 tests/usr.bin/xlint/lint1/msg_099.exp
--- a/tests/usr.bin/xlint/lint1/msg_099.exp     Wed Jan 06 20:38:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_099.exp     Thu Jan 07 00:38:46 2021 +0000
@@ -1,1 +1,1 @@
-msg_099.c(6): syntax error ':' [249]
+msg_099.c(10): undefined_variable undefined [99]



Home | Main Index | Thread Index | Old Index