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 tests/lint: add more details to tests fr...



details:   https://anonhg.NetBSD.org/src/rev/227b30214d26
branches:  trunk
changeset: 366816:227b30214d26
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jun 17 06:59:16 2022 +0000

description:
tests/lint: add more details to tests from msg_300 until msg_343

diffstat:

 tests/usr.bin/xlint/check-expect.lua  |   4 +-
 tests/usr.bin/xlint/lint1/msg_300.c   |  17 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_300.exp |   3 +-
 tests/usr.bin/xlint/lint1/msg_301.c   |  14 +++++++++--
 tests/usr.bin/xlint/lint1/msg_301.exp |   4 ++-
 tests/usr.bin/xlint/lint1/msg_302.c   |  39 ++++++++++++++++++++++++++++++++--
 tests/usr.bin/xlint/lint1/msg_302.exp |   4 ++-
 tests/usr.bin/xlint/lint1/msg_306.c   |  29 +++++++++++++++++++++++--
 tests/usr.bin/xlint/lint1/msg_306.exp |   3 +-
 tests/usr.bin/xlint/lint1/msg_308.c   |  11 +++++++--
 tests/usr.bin/xlint/lint1/msg_308.exp |   6 ++--
 tests/usr.bin/xlint/lint1/msg_309.c   |   5 ++-
 tests/usr.bin/xlint/lint1/msg_309.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_310.c   |  11 ++++++++-
 tests/usr.bin/xlint/lint1/msg_310.exp |   3 +-
 tests/usr.bin/xlint/lint1/msg_311.c   |  16 ++++++++++++-
 tests/usr.bin/xlint/lint1/msg_311.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_316.c   |  15 ++++++++++--
 tests/usr.bin/xlint/lint1/msg_316.exp |   3 +-
 tests/usr.bin/xlint/lint1/msg_318.c   |  17 +++++++++++++-
 tests/usr.bin/xlint/lint1/msg_318.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_320.c   |  16 +++++++++++--
 tests/usr.bin/xlint/lint1/msg_320.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_322.c   |  10 +++++---
 tests/usr.bin/xlint/lint1/msg_322.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_324.c   |  23 +++++++++++++-------
 tests/usr.bin/xlint/lint1/msg_324.exp |  12 +++++-----
 tests/usr.bin/xlint/lint1/msg_325.c   |  16 ++++++++++---
 tests/usr.bin/xlint/lint1/msg_325.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_326.c   |   6 ++--
 tests/usr.bin/xlint/lint1/msg_326.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_327.c   |  11 ++++++---
 tests/usr.bin/xlint/lint1/msg_327.exp |   4 +-
 tests/usr.bin/xlint/lint1/msg_329.c   |   5 ++-
 tests/usr.bin/xlint/lint1/msg_329.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_330.c   |  12 ++++++++--
 tests/usr.bin/xlint/lint1/msg_330.exp |   8 +++---
 tests/usr.bin/xlint/lint1/msg_331.c   |  12 ++++++++--
 tests/usr.bin/xlint/lint1/msg_331.exp |   8 +++---
 tests/usr.bin/xlint/lint1/msg_332.c   |  12 ++++++++--
 tests/usr.bin/xlint/lint1/msg_332.exp |   8 +++---
 tests/usr.bin/xlint/lint1/msg_334.c   |  11 +++++++--
 tests/usr.bin/xlint/lint1/msg_334.exp |   4 +-
 tests/usr.bin/xlint/lint1/msg_335.c   |  26 +++++++++++++++++------
 tests/usr.bin/xlint/lint1/msg_335.exp |  12 +++++-----
 tests/usr.bin/xlint/lint1/msg_336.c   |   8 +++++-
 tests/usr.bin/xlint/lint1/msg_336.exp |   4 +-
 tests/usr.bin/xlint/lint1/msg_337.c   |   8 +++++-
 tests/usr.bin/xlint/lint1/msg_337.exp |   4 +-
 tests/usr.bin/xlint/lint1/msg_338.c   |  12 +++++++---
 tests/usr.bin/xlint/lint1/msg_338.exp |  16 +++++++-------
 tests/usr.bin/xlint/lint1/msg_339.c   |  12 +++++++---
 tests/usr.bin/xlint/lint1/msg_339.exp |   8 +++---
 tests/usr.bin/xlint/lint1/msg_340.c   |   5 ++-
 tests/usr.bin/xlint/lint1/msg_340.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_343.c   |   8 ++++--
 tests/usr.bin/xlint/lint1/msg_343.exp |  16 +++++++-------
 57 files changed, 376 insertions(+), 163 deletions(-)

diffs (truncated from 1002 to 300 lines):

diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/check-expect.lua
--- a/tests/usr.bin/xlint/check-expect.lua      Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/check-expect.lua      Fri Jun 17 06:59:16 2022 +0000
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.17 2022/06/16 21:24:41 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.18 2022/06/17 06:59:16 rillig Exp $
 
 --[[
 
@@ -64,7 +64,7 @@
     -- only the raw message ID, without the actual message text,
     -- which makes them harder to understand without looking up more context.
     for comment in line:gmatch("/%* expect: (.-) %*/") do
-      if not fname:match("^msg_[012]") then
+      if not fname:match("^msg_") then
         add_expectation(0, comment)
       end
     end
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_300.c
--- a/tests/usr.bin/xlint/lint1/msg_300.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_300.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_300.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_300.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_300.c"
 
-// Test for message: old style definition [300]
+/* Test for message: old style definition [300] */
+
+/* lint1-flags: -wr */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: old style definition [300] */
+old_style(x)
+       double x;
+{
+       return x > 0.0;
+}
+
+/* expect+1: error: prototype does not match old style definition, arg #1 [299] */
+void old_style(char ch);
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_300.exp
--- a/tests/usr.bin/xlint/lint1/msg_300.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_300.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,2 @@
-msg_300.c(6): error: syntax error ':' [249]
+msg_300.c(16): error: prototype does not match old style definition, arg #1 [299]
+msg_300.c(9): old style definition [300]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_301.c
--- a/tests/usr.bin/xlint/lint1/msg_301.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_301.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: msg_301.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_301.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_301.c"
 
 // Test for message: array of incomplete type [301]
+// This message is not used.
+// TODO: This message occurs in the code but is deactivated.
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: struct 'incomplete' never defined [233] */
+struct incomplete;
+
+/* expect+1: error: 'var' has incomplete type 'incomplete struct incomplete' [31] */
+struct incomplete var[3];
+
+/* expect+1: error: cannot take size/alignment of incomplete type [143] */
+unsigned long sizeof_3 = sizeof(struct incomplete[3]);
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_301.exp
--- a/tests/usr.bin/xlint/lint1/msg_301.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_301.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,3 @@
-msg_301.c(6): error: syntax error ':' [249]
+msg_301.c(15): error: cannot take size/alignment of incomplete type [143]
+msg_301.c(9): warning: struct 'incomplete' never defined [233]
+msg_301.c(12): error: 'var' has incomplete type 'incomplete struct incomplete' [31]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_302.c
--- a/tests/usr.bin/xlint/lint1/msg_302.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_302.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,40 @@
-/*     $NetBSD: msg_302.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_302.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_302.c"
 
 // Test for message: %s returns pointer to automatic object [302]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void *
+return_arg(int arg)
+{
+       /* expect+1: warning: return_arg returns pointer to automatic object [302] */
+       return &arg;
+}
+
+void *
+return_local(void)
+{
+       int local = 3;
+       /* expect+1: warning: return_local returns pointer to automatic object [302] */
+       return &local;
+}
+
+void *
+return_local_array(_Bool cond)
+{
+       int local[5];
+       int *p = local;
+
+       /* XXX: lint doesn't track this indirection, but Clang-tidy does. */
+       if (cond)
+               return p;
+
+       /* expect+1: warning: return_local_array returns pointer to automatic object [302] */
+       return local + 5;
+}
+
+void *
+return_static(void)
+{
+       static int long_lived = 3;
+       return &long_lived;
+}
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_302.exp
--- a/tests/usr.bin/xlint/lint1/msg_302.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_302.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,3 @@
-msg_302.c(6): error: syntax error ':' [249]
+msg_302.c(10): warning: return_arg returns pointer to automatic object [302]
+msg_302.c(18): warning: return_local returns pointer to automatic object [302]
+msg_302.c(32): warning: return_local_array returns pointer to automatic object [302]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_306.c
--- a/tests/usr.bin/xlint/lint1/msg_306.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_306.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,30 @@
-/*     $NetBSD: msg_306.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_306.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_306.c"
 
 // Test for message: constant truncated by conversion, op %s [306]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+unsigned char
+to_u8(void)
+{
+       /* expect+1: warning: conversion of 'int' to 'unsigned char' is out of range [119] */
+       return 12345;
+}
+
+unsigned char
+and_u8(unsigned char a)
+{
+       /* XXX: unused bits in constant */
+       return a & 0x1234;
+}
+
+unsigned char
+or_u8(unsigned char a)
+{
+       /* expect+1: warning: constant truncated by conversion, op |= [306] */
+       a |= 0x1234;
+
+       /* XXX: Lint doesn't care about the expanded form of the same code. */
+       a = a | 0x1234;
+
+       return a;
+}
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_306.exp
--- a/tests/usr.bin/xlint/lint1/msg_306.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_306.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,2 @@
-msg_306.c(6): error: syntax error ':' [249]
+msg_306.c(10): warning: conversion of 'int' to 'unsigned char' is out of range [119]
+msg_306.c(24): warning: constant truncated by conversion, op |= [306]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_308.c
--- a/tests/usr.bin/xlint/lint1/msg_308.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_308.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_308.c,v 1.6 2021/04/05 01:35:34 rillig Exp $       */
+/*     $NetBSD: msg_308.c,v 1.7 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_308.c"
 
 // Test for message: invalid type for _Complex [308]
@@ -6,5 +6,10 @@
 float _Complex float_complex;
 double _Complex double_complex;
 long double _Complex long_double_complex;
-_Complex plain_complex;                        /* expect: 308 */
-int _Complex int_complex;              /* expect: 308 *//* expect: 4 */
+
+/* expect+1: error: invalid type for _Complex [308] */
+_Complex plain_complex;
+
+/* expect+2: error: invalid type for _Complex [308] */
+/* expect+1: error: illegal type combination [4] */
+int _Complex int_complex;
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_308.exp
--- a/tests/usr.bin/xlint/lint1/msg_308.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_308.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,3 +1,3 @@
-msg_308.c(9): error: invalid type for _Complex [308]
-msg_308.c(10): error: invalid type for _Complex [308]
-msg_308.c(10): error: illegal type combination [4]
+msg_308.c(11): error: invalid type for _Complex [308]
+msg_308.c(15): error: invalid type for _Complex [308]
+msg_308.c(15): error: illegal type combination [4]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_309.c
--- a/tests/usr.bin/xlint/lint1/msg_309.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_309.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_309.c,v 1.4 2021/05/16 10:18:25 rillig Exp $       */
+/*     $NetBSD: msg_309.c,v 1.5 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_309.c"
 
 // Test for message: extra bits set to 0 in conversion of '%s' to '%s', op '%s' [309]
@@ -20,7 +20,8 @@
         * bit mask here.  This situation may occur during migration from a
         * 32-bit to a 64-bit platform.
         */
-       if ((x & 0xffff0000) != 0)      /* expect: 309 */
+       /* expect+1: warning: extra bits set to 0 in conversion of 'unsigned int' to 'unsigned long long', op '&' [309] */
+       if ((x & 0xffff0000) != 0)
                return 16;
 
        /*
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_309.exp
--- a/tests/usr.bin/xlint/lint1/msg_309.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_309.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,1 @@
-msg_309.c(23): warning: extra bits set to 0 in conversion of 'unsigned int' to 'unsigned long long', op '&' [309]
+msg_309.c(24): warning: extra bits set to 0 in conversion of 'unsigned int' to 'unsigned long long', op '&' [309]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_310.c
--- a/tests/usr.bin/xlint/lint1/msg_310.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_310.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,14 @@
-/*     $NetBSD: msg_310.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_310.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_310.c"
 
 // Test for message: symbol renaming can't be used on function arguments [310]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
+/* expect+2: warning: argument 'callback' unused in function 'function' [231] */
+void
+function(int (*callback)(void) __symbolrename(argument))
+{
+}
+
+/* expect+1: error: syntax error ':' [249] */
+TODO: "Add example code that triggers the above message."
 TODO: "Add example code that almost triggers the above message."
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_310.exp
--- a/tests/usr.bin/xlint/lint1/msg_310.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_310.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,2 @@
-msg_310.c(6): error: syntax error ':' [249]
+msg_310.c(8): warning: argument 'callback' unused in function 'function' [231]
+msg_310.c(13): error: syntax error ':' [249]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_311.c
--- a/tests/usr.bin/xlint/lint1/msg_311.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_311.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,19 @@
-/*     $NetBSD: msg_311.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_311.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */
 # 3 "msg_311.c"
 
 // Test for message: symbol renaming can't be used on automatic variables [311]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
+typedef int (*callback)(void);
+
+callback
+example(void)
+{
+       int (*func)(void) __symbolrename(function);
+
+       func = (void *)0;
+       return func;
+}
+
+/* expect+1: error: syntax error ':' [249] */
+TODO: "Add example code that triggers the above message."
 TODO: "Add example code that almost triggers the above message."
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_311.exp
--- a/tests/usr.bin/xlint/lint1/msg_311.exp     Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_311.exp     Fri Jun 17 06:59:16 2022 +0000
@@ -1,1 +1,1 @@
-msg_311.c(6): error: syntax error ':' [249]
+msg_311.c(18): error: syntax error ':' [249]
diff -r 50b715bdfbdb -r 227b30214d26 tests/usr.bin/xlint/lint1/msg_316.c
--- a/tests/usr.bin/xlint/lint1/msg_316.c       Fri Jun 17 06:54:01 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_316.c       Fri Jun 17 06:59:16 2022 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_316.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_316.c,v 1.3 2022/06/17 06:59:16 rillig Exp $       */



Home | Main Index | Thread Index | Old Index