Module Name: src Committed By: rillig Date: Sat Feb 27 18:01:29 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_242.c msg_242.exp msg_277.c msg_277.exp msg_278.c msg_278.exp msg_279.c msg_279.exp Log Message: tests/lint: add tests for enum/int mismatch To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_242.c \ src/tests/usr.bin/xlint/lint1/msg_278.c \ src/tests/usr.bin/xlint/lint1/msg_279.c cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_242.exp \ src/tests/usr.bin/xlint/lint1/msg_277.exp \ src/tests/usr.bin/xlint/lint1/msg_278.exp \ src/tests/usr.bin/xlint/lint1/msg_279.exp cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_277.c 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_242.c diff -u src/tests/usr.bin/xlint/lint1/msg_242.c:1.2 src/tests/usr.bin/xlint/lint1/msg_242.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_242.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_242.c Sat Feb 27 18:01:29 2021 @@ -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); +} Index: src/tests/usr.bin/xlint/lint1/msg_278.c diff -u src/tests/usr.bin/xlint/lint1/msg_278.c:1.2 src/tests/usr.bin/xlint/lint1/msg_278.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_278.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_278.c Sat Feb 27 18:01:29 2021 @@ -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); +} Index: src/tests/usr.bin/xlint/lint1/msg_279.c diff -u src/tests/usr.bin/xlint/lint1/msg_279.c:1.2 src/tests/usr.bin/xlint/lint1/msg_279.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_279.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_279.c Sat Feb 27 18:01:29 2021 @@ -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 */ +} Index: src/tests/usr.bin/xlint/lint1/msg_242.exp diff -u src/tests/usr.bin/xlint/lint1/msg_242.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_242.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_242.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_242.exp Sat Feb 27 18:01:29 2021 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_277.exp diff -u src/tests/usr.bin/xlint/lint1/msg_277.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_277.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_277.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_277.exp Sat Feb 27 18:01:29 2021 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_278.exp diff -u src/tests/usr.bin/xlint/lint1/msg_278.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_278.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_278.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_278.exp Sat Feb 27 18:01:29 2021 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_279.exp diff -u src/tests/usr.bin/xlint/lint1/msg_279.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_279.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_279.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_279.exp Sat Feb 27 18:01:29 2021 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_277.c diff -u src/tests/usr.bin/xlint/lint1/msg_277.c:1.3 src/tests/usr.bin/xlint/lint1/msg_277.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_277.c:1.3 Mon Feb 22 15:09:50 2021 +++ src/tests/usr.bin/xlint/lint1/msg_277.c Sat Feb 27 18:01:29 2021 @@ -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); +}