Module Name: src Committed By: rillig Date: Sun Feb 21 14:49:23 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_186.c msg_186.exp Log Message: lint: add test for bit-field initialisation in traditional C To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_186.c cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_186.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_186.c diff -u src/tests/usr.bin/xlint/lint1/msg_186.c:1.2 src/tests/usr.bin/xlint/lint1/msg_186.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_186.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_186.c Sun Feb 21 14:49:23 2021 @@ -1,7 +1,19 @@ -/* $NetBSD: msg_186.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */ +/* $NetBSD: msg_186.c,v 1.3 2021/02/21 14:49:23 rillig Exp $ */ # 3 "msg_186.c" -// Test for message: bit-field initialisation is illegal in traditional C [186] +/* Test for message: bit-field initialisation is illegal in traditional C [186] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -tw */ + +struct bit_field { + unsigned one: 1; + unsigned three: 3; + unsigned two: 2; +}; + +struct bit_field bit_field = { + 1, + 3.0, /* expect: 186 */ + 2 +}; +/* XXX: The message is misleading. Initialisation using integers is ok. */ Index: src/tests/usr.bin/xlint/lint1/msg_186.exp diff -u src/tests/usr.bin/xlint/lint1/msg_186.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_186.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_186.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_186.exp Sun Feb 21 14:49:23 2021 @@ -1 +1,8 @@ -msg_186.c(6): syntax error ':' [249] +(1): warning: 'long double' is illegal in traditional C [266] +(1): warning: function prototypes are illegal in traditional C [270] +(2): warning: 'long double' is illegal in traditional C [266] +(2): warning: function prototypes are illegal in traditional C [270] +(3): warning: 'long double' is illegal in traditional C [266] +(3): warning: 'long double' is illegal in traditional C [266] +(3): warning: function prototypes are illegal in traditional C [270] +msg_186.c(16): warning: bit-field initialisation is illegal in traditional C [186]