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: require C11 for _Generic
details: https://anonhg.NetBSD.org/src/rev/cd4b8e76d4a7
branches: trunk
changeset: 379925:cd4b8e76d4a7
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jun 27 19:10:29 2021 +0000
description:
lint: require C11 for _Generic
This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.
Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.
Currently it is not possible to say "allow GNU extensions but not C11".
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 ++--
tests/usr.bin/xlint/lint1/msg_345.c | 14 ++++++++++++++
tests/usr.bin/xlint/lint1/msg_345.exp | 1 +
tests/usr.bin/xlint/lint1/t_integration.sh | 4 ++--
usr.bin/xlint/lint1/cgram.y | 6 ++++--
usr.bin/xlint/lint1/err.c | 5 +++--
7 files changed, 29 insertions(+), 9 deletions(-)
diffs (126 lines):
diff -r 69ca36024b2c -r cd4b8e76d4a7 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jun 27 18:54:14 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jun 27 19:10:29 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1066 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: mi,v 1.1067 2021/06/27 19:10:29 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6924,6 +6924,8 @@
./usr/tests/usr.bin/xlint/lint1/msg_343.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_344.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_344.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_345.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_345.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf
diff -r 69ca36024b2c -r cd4b8e76d4a7 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jun 27 18:54:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jun 27 19:10:29 2021 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.67 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: Makefile,v 1.68 2021/06/27 19:10:29 rillig Exp $
NOMAN= # defined
-MAX_MESSAGE= 344 # see lint1/err.c
+MAX_MESSAGE= 345 # see lint1/err.c
.include <bsd.own.mk>
diff -r 69ca36024b2c -r cd4b8e76d4a7 tests/usr.bin/xlint/lint1/msg_345.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_345.c Sun Jun 27 19:10:29 2021 +0000
@@ -0,0 +1,14 @@
+/* $NetBSD: msg_345.c,v 1.1 2021/06/27 19:10:29 rillig Exp $ */
+# 3 "msg_345.c"
+
+// Test for message: generic selection requires C11 or later [345]
+
+/* Omit flag -g since it silences c11ism. */
+/* lint1-flags: -Sw */
+
+int
+test(int x)
+{
+ /* expect+1: generic selection requires C11 or later [345] */
+ return _Generic(x, default: 3);
+}
diff -r 69ca36024b2c -r cd4b8e76d4a7 tests/usr.bin/xlint/lint1/msg_345.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_345.exp Sun Jun 27 19:10:29 2021 +0000
@@ -0,0 +1,1 @@
+msg_345.c(13): error: generic selection requires C11 or later [345]
diff -r 69ca36024b2c -r cd4b8e76d4a7 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 27 18:54:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 27 19:10:29 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.60 2021/06/27 18:48:45 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.61 2021/06/27 19:10:29 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -211,7 +211,7 @@ all_messages_body()
failed=""
- for msg in $(seq 0 344); do
+ for msg in $(seq 0 345); do
name="$(printf 'msg_%03d.c' "$msg")"
check_lint1 "$name" \
|| failed="$failed${failed:+ }$name"
diff -r 69ca36024b2c -r cd4b8e76d4a7 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jun 27 18:54:14 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jun 27 19:10:29 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.235 2021/06/27 18:54:14 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.236 2021/06/27 19:10:29 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.235 2021/06/27 18:54:14 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.236 2021/06/27 19:10:29 rillig Exp $");
#endif
#include <limits.h>
@@ -1683,6 +1683,8 @@ switch_expr:
/* TODO: c11ism */
generic_selection: /* C11 6.5.1.1 */
T_GENERIC T_LPAREN expr T_COMMA generic_assoc_list T_RPAREN {
+ /* generic selection requires C11 or later */
+ c11ism(345);
$$ = $3;
}
;
diff -r 69ca36024b2c -r cd4b8e76d4a7 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jun 27 18:54:14 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jun 27 19:10:29 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.119 2021/05/16 11:11:36 rillig Exp $ */
+/* $NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.119 2021/05/16 11:11:36 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.120 2021/06/27 19:10:29 rillig Exp $");
#endif
#include <sys/types.h>
@@ -399,6 +399,7 @@ const char *const msgs[] = {
"argument to '%s' must be cast to 'unsigned char', not to '%s'", /* 342 */
"static array size is a C11 extension", /* 343 */
"bit-field of type plain 'int' has implementation-defined signedness", /* 344 */
+ "generic selection requires C11 or later", /* 345 */
};
static struct include_level {
Home |
Main Index |
Thread Index |
Old Index