Module Name: src Committed By: rillig Date: Sun Feb 21 10:12:30 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_210.c msg_210.exp Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_210.c cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_210.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_210.c diff -u src/tests/usr.bin/xlint/lint1/msg_210.c:1.2 src/tests/usr.bin/xlint/lint1/msg_210.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_210.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_210.c Sun Feb 21 10:12:29 2021 @@ -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 */ Index: src/tests/usr.bin/xlint/lint1/msg_210.exp diff -u src/tests/usr.bin/xlint/lint1/msg_210.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_210.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_210.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_210.exp Sun Feb 21 10:12:29 2021 @@ -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]