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 test for enum mismatch i...



details:   https://anonhg.NetBSD.org/src/rev/53b62d5c6945
branches:  trunk
changeset: 959658:53b62d5c6945
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 10:12:29 2021 +0000

description:
lint: add test for enum mismatch in initialization

This warning is currently not user-friendly because it omits any type
information, but that information is crucial.

diffstat:

 tests/usr.bin/xlint/lint1/msg_210.c   |  24 +++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_210.exp |   3 ++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 909cae3e01db -r 53b62d5c6945 tests/usr.bin/xlint/lint1/msg_210.c
--- a/tests/usr.bin/xlint/lint1/msg_210.c       Sun Feb 21 10:03:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_210.c       Sun Feb 21 10:12:29 2021 +0000
@@ -1,7 +1,25 @@
-/*     $NetBSD: msg_210.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_210.c,v 1.3 2021/02/21 10:12:29 rillig Exp $       */
 # 3 "msg_210.c"
 
 // Test for message: enum type mismatch in initialisation [210]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+enum A {
+       A1
+};
+
+enum B {
+       B1
+};
+
+typedef enum {
+       C1
+} C;
+
+typedef enum {
+       D1
+} D;
+
+enum A a1 = A1;
+enum A a2 = B1;                        /* expect: 210 */
+C c1 = C1;
+C c2 = D1;                     /* expect: 210 */
diff -r 909cae3e01db -r 53b62d5c6945 tests/usr.bin/xlint/lint1/msg_210.exp
--- a/tests/usr.bin/xlint/lint1/msg_210.exp     Sun Feb 21 10:03:35 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_210.exp     Sun Feb 21 10:12:29 2021 +0000
@@ -1,1 +1,2 @@
-msg_210.c(6): syntax error ':' [249]
+msg_210.c(23): warning: enum type mismatch in initialisation [210]
+msg_210.c(25): warning: enum type mismatch in initialisation [210]



Home | Main Index | Thread Index | Old Index