Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: warn about anonymous struct in str...
details: https://anonhg.NetBSD.org/src/rev/1dbda9b59f95
branches: trunk
changeset: 365777:1dbda9b59f95
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 24 15:55:50 2022 +0000
description:
lint: warn about anonymous struct in struct, in plain C99 mode
diffstat:
tests/usr.bin/xlint/lint1/msg_049.c | 9 ++-------
tests/usr.bin/xlint/lint1/msg_049.exp | 2 +-
usr.bin/xlint/lint1/cgram.y | 6 +++---
3 files changed, 6 insertions(+), 11 deletions(-)
diffs (54 lines):
diff -r c7cbd4dbbd24 -r 1dbda9b59f95 tests/usr.bin/xlint/lint1/msg_049.c
--- a/tests/usr.bin/xlint/lint1/msg_049.c Sun Apr 24 15:07:08 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_049.c Sun Apr 24 15:55:50 2022 +0000
@@ -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;
diff -r c7cbd4dbbd24 -r 1dbda9b59f95 tests/usr.bin/xlint/lint1/msg_049.exp
--- a/tests/usr.bin/xlint/lint1/msg_049.exp Sun Apr 24 15:07:08 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_049.exp Sun Apr 24 15:55:50 2022 +0000
@@ -1,1 +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]
diff -r c7cbd4dbbd24 -r 1dbda9b59f95 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Apr 24 15:07:08 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Apr 24 15:55:50 2022 +0000
@@ -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 @@
| 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)) {
Home |
Main Index |
Thread Index |
Old Index