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 bit-field initi...



details:   https://anonhg.NetBSD.org/src/rev/6d31e3afb4a2
branches:  trunk
changeset: 959670:6d31e3afb4a2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 14:49:23 2021 +0000

description:
lint: add test for bit-field initialisation in traditional C

diffstat:

 tests/usr.bin/xlint/lint1/msg_186.c   |  20 ++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_186.exp |   9 ++++++++-
 2 files changed, 24 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 0cd0e3b309f3 -r 6d31e3afb4a2 tests/usr.bin/xlint/lint1/msg_186.c
--- a/tests/usr.bin/xlint/lint1/msg_186.c       Sun Feb 21 14:19:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_186.c       Sun Feb 21 14:49:23 2021 +0000
@@ -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] */
+
+/* lint1-flags: -tw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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. */
diff -r 0cd0e3b309f3 -r 6d31e3afb4a2 tests/usr.bin/xlint/lint1/msg_186.exp
--- a/tests/usr.bin/xlint/lint1/msg_186.exp     Sun Feb 21 14:19:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_186.exp     Sun Feb 21 14:49:23 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index