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: in strict C mode, warn about initi...
details: https://anonhg.NetBSD.org/src/rev/e464f0e56c5c
branches: trunk
changeset: 960091:e464f0e56c5c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 07 19:42:54 2021 +0000
description:
lint: in strict C mode, warn about initialization with '[a ... b]'
https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 ++--
tests/usr.bin/xlint/lint1/msg_340.c | 19 +++++++++++++++++++
tests/usr.bin/xlint/lint1/msg_340.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, 34 insertions(+), 9 deletions(-)
diffs (136 lines):
diff -r ac8675b1d1a2 -r e464f0e56c5c distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Mar 07 18:02:45 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Mar 07 19:42:54 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1025 2021/03/06 17:56:33 rillig Exp $
+# $NetBSD: mi,v 1.1026 2021/03/07 19:42:54 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6730,6 +6730,8 @@
./usr/tests/usr.bin/xlint/lint1/msg_338.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_339.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_339.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_340.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_340.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
diff -r ac8675b1d1a2 -r e464f0e56c5c tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Mar 07 18:02:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Mar 07 19:42:54 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.34 2021/02/28 22:12:16 rillig Exp $
+# $NetBSD: Makefile,v 1.35 2021/03/07 19:42:54 rillig Exp $
NOMAN= # defined
@@ -96,7 +96,7 @@
FILES+= d_typefun.c
FILES+= d_typename_as_var.c
FILES+= d_zero_sized_arrays.c
-FILES+= ${:U0 ${:U:range=339}:C,^.$,0&,:C,^..$,0&,:@msg@msg_${msg}.c msg_${msg}.exp@}
+FILES+= ${:U0 ${:U:range=340}:C,^.$,0&,:C,^..$,0&,:@msg@msg_${msg}.c msg_${msg}.exp@}
# Note: only works for adding tests.
# To remove a test, the $$mi file must be edited manually.
diff -r ac8675b1d1a2 -r e464f0e56c5c tests/usr.bin/xlint/lint1/msg_340.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_340.c Sun Mar 07 19:42:54 2021 +0000
@@ -0,0 +1,19 @@
+/* $NetBSD: msg_340.c,v 1.1 2021/03/07 19:42:54 rillig Exp $ */
+# 3 "msg_340.c"
+
+// Test for message: initialization with '[a...b]' is a GNU extension [340]
+
+/*
+ * In strict C mode, GNU extensions are flagged as such.
+ */
+
+/* lint1-flags: -Ssw */
+
+int
+example(void)
+{
+ int numbers[] = {
+ [2 ... 3] = 12 /* expect: 340 */
+ };
+ return numbers[0];
+}
diff -r ac8675b1d1a2 -r e464f0e56c5c tests/usr.bin/xlint/lint1/msg_340.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_340.exp Sun Mar 07 19:42:54 2021 +0000
@@ -0,0 +1,1 @@
+msg_340.c(16): initialization with '[a...b]' is a GNU extension [340]
diff -r ac8675b1d1a2 -r e464f0e56c5c tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sun Mar 07 18:02:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sun Mar 07 19:42:54 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.32 2021/02/28 22:12:16 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.33 2021/03/07 19:42:54 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -187,7 +187,7 @@
srcdir="$(atf_get_srcdir)"
ok="true"
- for msg in $(seq 0 339); do
+ for msg in $(seq 0 340); do
base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
flags="$(extract_flags "${base}.c")"
diff -r ac8675b1d1a2 -r e464f0e56c5c usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Mar 07 18:02:45 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Mar 07 19:42:54 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.165 2021/03/07 18:02:45 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.166 2021/03/07 19:42:54 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.165 2021/03/07 18:02:45 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.166 2021/03/07 19:42:54 rillig Exp $");
#endif
#include <limits.h>
@@ -1353,6 +1353,8 @@
| constant T_ELLIPSIS constant {
$$.lo = toicon($1, 1);
$$.hi = toicon($3, 1);
+ /* initialization with '[a...b]' is a GNU extension */
+ gnuism(340);
}
;
diff -r ac8675b1d1a2 -r e464f0e56c5c usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Mar 07 18:02:45 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Mar 07 19:42:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.86 2021/02/28 02:45:37 rillig Exp $ */
+/* $NetBSD: err.c,v 1.87 2021/03/07 19:42:54 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.86 2021/02/28 02:45:37 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.87 2021/03/07 19:42:54 rillig Exp $");
#endif
#include <sys/types.h>
@@ -399,6 +399,7 @@
"right operand of '%s' must not be bool", /* 337 */
"option '%c' should be handled in the switch", /* 338 */
"option '%c' should be listed in the options string", /* 339 */
+ "initialization with '[a...b]' is a GNU extension", /* 340 */
};
/*
Home |
Main Index |
Thread Index |
Old Index