Module Name: src
Committed By: rillig
Date: Tue Dec 14 18:26:39 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_102.c msg_102.exp
Log Message:
tests/lint: demonstrate missing support for anonymous members
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_102.c \
src/tests/usr.bin/xlint/lint1/msg_102.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_102.c
diff -u src/tests/usr.bin/xlint/lint1/msg_102.c:1.2 src/tests/usr.bin/xlint/lint1/msg_102.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_102.c:1.2 Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_102.c Tue Dec 14 18:26:39 2021
@@ -1,7 +1,29 @@
-/* $NetBSD: msg_102.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_102.c,v 1.3 2021/12/14 18:26:39 rillig Exp $ */
# 3 "msg_102.c"
// Test for message: illegal member use: %s [102]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+// Anonymous members are defined in C11 6.7.2.1p2.
+
+struct bit_fields_and_bits {
+ union {
+ struct {
+ unsigned bit_0:1;
+ unsigned bit_1:1;
+ };
+ unsigned bits;
+ };
+};
+
+static inline _Bool
+eq(const struct bit_fields_and_bits *a, const struct bit_fields_and_bits *b)
+{
+ /*
+ * TODO: Once this is fixed, enable lint in
+ * external/mit/xorg/lib/dri.old/Makefile again.
+ */
+ /* TODO: Add support for C11 anonymous struct and union members. */
+ /* expect+2: error: illegal member use: bits [102] */
+ /* expect+1: error: illegal member use: bits [102] */
+ return a->bits == b->bits;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_102.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_102.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_102.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_102.exp:1.2 Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_102.exp Tue Dec 14 18:26:39 2021
@@ -1 +1,2 @@
-msg_102.c(6): error: syntax error ':' [249]
+msg_102.c(28): error: illegal member use: bits [102]
+msg_102.c(28): error: illegal member use: bits [102]