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: add tests for enum/int...
details: https://anonhg.NetBSD.org/src/rev/18ab144e7131
branches: trunk
changeset: 953145:18ab144e7131
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 27 18:01:29 2021 +0000
description:
tests/lint: add tests for enum/int mismatch
diffstat:
tests/usr.bin/xlint/lint1/msg_242.c | 26 +++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_242.exp | 3 ++-
tests/usr.bin/xlint/lint1/msg_277.c | 26 +++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_277.exp | 3 ++-
tests/usr.bin/xlint/lint1/msg_278.c | 22 +++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_278.exp | 3 ++-
tests/usr.bin/xlint/lint1/msg_279.c | 24 +++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_279.exp | 3 ++-
8 files changed, 94 insertions(+), 16 deletions(-)
diffs (158 lines):
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_242.c
--- a/tests/usr.bin/xlint/lint1/msg_242.c Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_242.c Sat Feb 27 18:01:29 2021 +0000
@@ -1,7 +1,27 @@
-/* $NetBSD: msg_242.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_242.c,v 1.3 2021/02/27 18:01:29 rillig Exp $ */
# 3 "msg_242.c"
// Test for message: combination of '%s' and '%s', op %s [242]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -e */
+
+enum E {
+ E1
+};
+
+void sink_enum(enum E);
+void sink_int(int);
+
+void
+example(enum E e, int i)
+{
+ enum E e2 = e;
+ enum E e3 = i; /* expect: 242 */
+ int i2 = e; /* expect: 242 */
+ int i3 = i;
+
+ sink_enum(e2);
+ sink_enum(e3);
+ sink_int(i2);
+ sink_int(i3);
+}
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_242.exp
--- a/tests/usr.bin/xlint/lint1/msg_242.exp Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_242.exp Sat Feb 27 18:01:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_242.c(6): syntax error ':' [249]
+msg_242.c(19): warning: combination of 'enum E' and 'int', op = [242]
+msg_242.c(20): warning: combination of 'int' and 'enum E', op = [242]
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_277.c
--- a/tests/usr.bin/xlint/lint1/msg_277.c Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_277.c Sat Feb 27 18:01:29 2021 +0000
@@ -1,7 +1,27 @@
-/* $NetBSD: msg_277.c,v 1.3 2021/02/22 15:09:50 rillig Exp $ */
+/* $NetBSD: msg_277.c,v 1.4 2021/02/27 18:01:29 rillig Exp $ */
# 3 "msg_277.c"
// Test for message: initialization of '%s' with '%s' [277]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -e */
+
+enum E {
+ E1
+};
+
+void sink_enum(enum E);
+void sink_int(int);
+
+void
+example(enum E e, int i)
+{
+ enum E e2 = e;
+ enum E e3 = { i }; /* expect: 277 */
+ int i2 = { e }; /* expect: 277 */
+ int i3 = i;
+
+ sink_enum(e2);
+ sink_enum(e3);
+ sink_int(i2);
+ sink_int(i3);
+}
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_277.exp
--- a/tests/usr.bin/xlint/lint1/msg_277.exp Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_277.exp Sat Feb 27 18:01:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_277.c(6): syntax error ':' [249]
+msg_277.c(19): warning: initialization of 'enum E' with 'int' [277]
+msg_277.c(20): warning: initialization of 'int' with 'enum E' [277]
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_278.c
--- a/tests/usr.bin/xlint/lint1/msg_278.c Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_278.c Sat Feb 27 18:01:29 2021 +0000
@@ -1,7 +1,23 @@
-/* $NetBSD: msg_278.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_278.c,v 1.3 2021/02/27 18:01:29 rillig Exp $ */
# 3 "msg_278.c"
// Test for message: combination of '%s' and '%s', arg #%d [278]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -e */
+
+enum E {
+ E1
+};
+
+void sink_enum(enum E);
+void sink_int(int);
+
+void
+example(enum E e, int i)
+{
+ sink_enum(e);
+ sink_enum(i); /* expect: 278 */
+
+ sink_int(e); /* expect: 278 */
+ sink_int(i);
+}
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_278.exp
--- a/tests/usr.bin/xlint/lint1/msg_278.exp Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_278.exp Sat Feb 27 18:01:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_278.c(6): syntax error ':' [249]
+msg_278.c(19): warning: combination of 'enum E' and 'int', arg #1 [278]
+msg_278.c(21): warning: combination of 'int' and 'enum E', arg #1 [278]
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_279.c
--- a/tests/usr.bin/xlint/lint1/msg_279.c Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_279.c Sat Feb 27 18:01:29 2021 +0000
@@ -1,7 +1,25 @@
-/* $NetBSD: msg_279.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_279.c,v 1.3 2021/02/27 18:01:29 rillig Exp $ */
# 3 "msg_279.c"
// Test for message: combination of '%s' and '%s' in return [279]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -e */
+
+enum E {
+ E1
+};
+
+void sink_enum(enum E);
+void sink_int(int);
+
+enum E
+returning_enum(int i)
+{
+ return i; /* expect: 279 */
+}
+
+int
+returning_int(enum E e)
+{
+ return e; /* expect: 279 */
+}
diff -r 11c9085cf3e3 -r 18ab144e7131 tests/usr.bin/xlint/lint1/msg_279.exp
--- a/tests/usr.bin/xlint/lint1/msg_279.exp Sat Feb 27 17:16:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_279.exp Sat Feb 27 18:01:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_279.c(6): syntax error ':' [249]
+msg_279.c(18): warning: combination of 'enum E' and 'int' in return [279]
+msg_279.c(24): warning: combination of 'int' and 'enum E' in return [279]
Home |
Main Index |
Thread Index |
Old Index