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 tests/lint: test some more messages
details: https://anonhg.NetBSD.org/src/rev/fee84d459c17
branches: trunk
changeset: 1023155:fee84d459c17
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Aug 27 20:49:25 2021 +0000
description:
tests/lint: test some more messages
diffstat:
tests/usr.bin/xlint/lint1/msg_222.c | 30 +++++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_222.exp | 6 +++++-
tests/usr.bin/xlint/lint1/msg_226.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_226.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_233.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_233.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_235.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_235.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_252.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_252.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_257.c | 27 ++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_257.exp | 5 ++++-
tests/usr.bin/xlint/lint1/msg_289.c | 10 +++++++---
tests/usr.bin/xlint/lint1/msg_289.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_297.c | 23 ++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_297.exp | 3 ++-
16 files changed, 106 insertions(+), 32 deletions(-)
diffs (234 lines):
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_222.c
--- a/tests/usr.bin/xlint/lint1/msg_222.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_222.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,31 @@
-/* $NetBSD: msg_222.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_222.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_222.c"
// Test for message: conversion of negative constant to unsigned type [222]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: initialization of unsigned with negative constant [221] */
+unsigned int global = -1;
+
+void take_unsigned_int(unsigned int);
+
+void
+function(void)
+{
+ /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ unsigned int local = -1;
+
+ /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ take_unsigned_int(-1);
+
+ if (local & -1)
+ return;
+
+ /* expect+1: warning: comparison of unsigned int with negative constant, op < [162] */
+ if (local < -1)
+ return;
+
+ local &= -1;
+
+ /* expect+1: warning: conversion of negative constant to unsigned type [222] */
+ local += -1;
+}
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_222.exp
--- a/tests/usr.bin/xlint/lint1/msg_222.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_222.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,5 @@
-msg_222.c(6): error: syntax error ':' [249]
+msg_222.c(7): warning: initialization of unsigned with negative constant [221]
+msg_222.c(15): warning: initialization of unsigned with negative constant [221]
+msg_222.c(18): warning: conversion of negative constant to unsigned type, arg #1 [296]
+msg_222.c(24): warning: comparison of unsigned int with negative constant, op < [162]
+msg_222.c(30): warning: conversion of negative constant to unsigned type [222]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_226.c
--- a/tests/usr.bin/xlint/lint1/msg_226.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_226.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_226.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_226.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_226.c"
// Test for message: static variable %s unused [226]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: static variable unused unused [226] */
+static int unused;
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_226.exp
--- a/tests/usr.bin/xlint/lint1/msg_226.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_226.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,1 @@
-msg_226.c(6): error: syntax error ':' [249]
+msg_226.c(7): warning: static variable unused unused [226]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_233.c
--- a/tests/usr.bin/xlint/lint1/msg_233.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_233.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_233.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_233.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_233.c"
// Test for message: struct %s never defined [233]
-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 declared_but_not_defined never defined [233] */
+struct declared_but_not_defined;
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_233.exp
--- a/tests/usr.bin/xlint/lint1/msg_233.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_233.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,1 @@
-msg_233.c(6): error: syntax error ':' [249]
+msg_233.c(7): warning: struct declared_but_not_defined never defined [233]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_235.c
--- a/tests/usr.bin/xlint/lint1/msg_235.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_235.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_235.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_235.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_235.c"
// Test for message: enum %s never defined [235]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: enum declared_but_not_defined never defined [235] */
+enum declared_but_not_defined;
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_235.exp
--- a/tests/usr.bin/xlint/lint1/msg_235.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_235.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,1 @@
-msg_235.c(6): error: syntax error ':' [249]
+msg_235.c(7): warning: enum declared_but_not_defined never defined [235]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_252.c
--- a/tests/usr.bin/xlint/lint1/msg_252.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_252.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_252.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_252.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_252.c"
// Test for message: integer constant out of range [252]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: integer constant out of range [252] */
+int constant = 1111111111111111111111111111111111111111111111111111;
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_252.exp
--- a/tests/usr.bin/xlint/lint1/msg_252.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_252.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,1 @@
-msg_252.c(6): error: syntax error ':' [249]
+msg_252.c(7): warning: integer constant out of range [252]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_257.c
--- a/tests/usr.bin/xlint/lint1/msg_257.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_257.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,28 @@
-/* $NetBSD: msg_257.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_257.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_257.c"
// Test for message: extra characters in lint comment [257]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void take(const void *);
+
+/* expect+1: warning: extra characters in lint comment [257] */
+/* FALLTHROUGH 3 */
+
+/* expect+1: warning: extra characters in lint comment [257] */
+/* FALLTHROUGH extra */
+
+/* PRINTFLIKE 7 */
+void
+my_printf(const char *fmt)
+/* expect+1: warning: argument number mismatch with directive: */
+{
+ take(fmt);
+}
+
+/* expect+1: warning: extra characters in lint comment [257] */
+/* SCANFLIKE extra */
+void
+my_scanf(const char *fmt)
+{
+ take(fmt);
+}
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_257.exp
--- a/tests/usr.bin/xlint/lint1/msg_257.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_257.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,4 @@
-msg_257.c(6): error: syntax error ':' [249]
+msg_257.c(9): warning: extra characters in lint comment [257]
+msg_257.c(12): warning: extra characters in lint comment [257]
+msg_257.c(18): warning: argument number mismatch with directive: /* PRINTFLIKE */ [283]
+msg_257.c(23): warning: extra characters in lint comment [257]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_289.c
--- a/tests/usr.bin/xlint/lint1/msg_289.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_289.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,11 @@
-/* $NetBSD: msg_289.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_289.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_289.c"
// Test for message: can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */ [289]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* PRINTFLIKE */ /* SCANFLIKE */
+void
+both(void)
+/* expect+1: warning: can't be used together */
+{
+}
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_289.exp
--- a/tests/usr.bin/xlint/lint1/msg_289.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_289.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,1 @@
-msg_289.c(6): error: syntax error ':' [249]
+msg_289.c(10): warning: can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */ [289]
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_297.c
--- a/tests/usr.bin/xlint/lint1/msg_297.c Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_297.c Fri Aug 27 20:49:25 2021 +0000
@@ -1,7 +1,24 @@
-/* $NetBSD: msg_297.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_297.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */
# 3 "msg_297.c"
// Test for message: conversion to '%s' may sign-extend incorrectly, arg #%d [297]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -P -a -p */
+
+void take_unsigned_long_long(unsigned long long);
+void take_long_long(long long);
+
+void
+caller(signed int si, unsigned int ui)
+{
+
+ /* expect+1: warning: conversion to 'unsigned long long' may sign-extend incorrectly, arg #1 [297] */
+ take_unsigned_long_long(si);
+
+ take_unsigned_long_long(ui);
+
+ take_long_long(si);
+
+ /* expect+1: warning: conversion to 'long long' may sign-extend incorrectly, arg #1 [297] */
+ take_long_long(ui);
+}
diff -r e234202286b6 -r fee84d459c17 tests/usr.bin/xlint/lint1/msg_297.exp
--- a/tests/usr.bin/xlint/lint1/msg_297.exp Fri Aug 27 20:19:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_297.exp Fri Aug 27 20:49:25 2021 +0000
@@ -1,1 +1,2 @@
-msg_297.c(6): error: syntax error ':' [249]
+msg_297.c(16): warning: conversion to 'unsigned long long' may sign-extend incorrectly, arg #1 [297]
+msg_297.c(23): warning: conversion to 'long long' may sign-extend incorrectly, arg #1 [297]
Home |
Main Index |
Thread Index |
Old Index