Module Name: src
Committed By: rillig
Date: Sun Apr 24 15:55:50 UTC 2022
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_049.c msg_049.exp
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: warn about anonymous struct in struct, in plain C99 mode
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_049.c \
src/tests/usr.bin/xlint/lint1/msg_049.exp
cvs rdiff -u -r1.396 -r1.397 src/usr.bin/xlint/lint1/cgram.y
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_049.c
diff -u src/tests/usr.bin/xlint/lint1/msg_049.c:1.4 src/tests/usr.bin/xlint/lint1/msg_049.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_049.c:1.4 Sun Feb 27 11:40:30 2022
+++ src/tests/usr.bin/xlint/lint1/msg_049.c Sun Apr 24 15:55:50 2022
@@ -1,14 +1,9 @@
-/* $NetBSD: msg_049.c,v 1.4 2022/02/27 11:40:30 rillig Exp $ */
+/* $NetBSD: msg_049.c,v 1.5 2022/04/24 15:55:50 rillig Exp $ */
# 3 "msg_049.c"
/* Test for message: anonymous struct/union members is a C11 feature [49] */
-/* lint1-flags: -sw */
-
-/*
- * FIXME: C99 does not allow anonymous struct/union members, that's a GCC
- * extension that got incorporated into C11.
- */
+/* lint1-flags: -Sw */
struct {
unsigned int flag: 1;
Index: src/tests/usr.bin/xlint/lint1/msg_049.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_049.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_049.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_049.exp:1.4 Sun Feb 27 11:40:30 2022
+++ src/tests/usr.bin/xlint/lint1/msg_049.exp Sun Apr 24 15:55:50 2022
@@ -1 +1 @@
-msg_049.c(25): warning: anonymous struct/union members is a C11 feature [49]
+msg_049.c(20): warning: anonymous struct/union members is a C11 feature [49]
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.396 src/usr.bin/xlint/lint1/cgram.y:1.397
--- src/usr.bin/xlint/lint1/cgram.y:1.396 Sun Apr 24 13:38:57 2022
+++ src/usr.bin/xlint/lint1/cgram.y Sun Apr 24 15:55:50 2022
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.396 2022/04/24 13:38:57 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.397 2022/04/24 15:55:50 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.396 2022/04/24 13:38:57 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.397 2022/04/24 15:55:50 rillig Exp $");
#endif
#include <limits.h>
@@ -979,7 +979,7 @@ struct_declaration: /* C99 6.7.2.1 */
| begin_type_specifier_qualifier_list end_type type_attribute_opt
T_SEMI {
symtyp = FVFT;
- if (!Sflag)
+ if (!allow_c11 && !allow_gcc)
/* anonymous struct/union members is a C11 feature */
warning(49);
if (is_struct_or_union(dcs->d_type->t_tspec)) {