lint: in strict C mode, warn about initialization with '[a ... b]'
https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html
This commit is contained in:
parent
8c49e96e03
commit
7bd1775519
@ -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.
|
# 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_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.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_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/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 tests-usr.bin-tests compattestfile,atf
|
||||||
./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
|
./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
|
||||||
|
@ -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
|
NOMAN= # defined
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ FILES+= d_type_question_colon.c
|
|||||||
FILES+= d_typefun.c
|
FILES+= d_typefun.c
|
||||||
FILES+= d_typename_as_var.c
|
FILES+= d_typename_as_var.c
|
||||||
FILES+= d_zero_sized_arrays.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.
|
# Note: only works for adding tests.
|
||||||
# To remove a test, the $$mi file must be edited manually.
|
# To remove a test, the $$mi file must be edited manually.
|
||||||
|
19
tests/usr.bin/xlint/lint1/msg_340.c
Normal file
19
tests/usr.bin/xlint/lint1/msg_340.c
Normal file
@ -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];
|
||||||
|
}
|
1
tests/usr.bin/xlint/lint1/msg_340.exp
Normal file
1
tests/usr.bin/xlint/lint1/msg_340.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
msg_340.c(16): initialization with '[a...b]' is a GNU extension [340]
|
@ -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.
|
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
@ -187,7 +187,7 @@ all_messages_body()
|
|||||||
srcdir="$(atf_get_srcdir)"
|
srcdir="$(atf_get_srcdir)"
|
||||||
ok="true"
|
ok="true"
|
||||||
|
|
||||||
for msg in $(seq 0 339); do
|
for msg in $(seq 0 340); do
|
||||||
base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
|
base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
|
||||||
flags="$(extract_flags "${base}.c")"
|
flags="$(extract_flags "${base}.c")"
|
||||||
|
|
||||||
|
@ -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.
|
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__RCSID) && !defined(lint)
|
#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
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -1353,6 +1353,8 @@ range:
|
|||||||
| constant T_ELLIPSIS constant {
|
| constant T_ELLIPSIS constant {
|
||||||
$$.lo = toicon($1, 1);
|
$$.lo = toicon($1, 1);
|
||||||
$$.hi = toicon($3, 1);
|
$$.hi = toicon($3, 1);
|
||||||
|
/* initialization with '[a...b]' is a GNU extension */
|
||||||
|
gnuism(340);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#if defined(__RCSID) && !defined(lint)
|
#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
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -399,6 +399,7 @@ const char *msgs[] = {
|
|||||||
"right operand of '%s' must not be bool", /* 337 */
|
"right operand of '%s' must not be bool", /* 337 */
|
||||||
"option '%c' should be handled in the switch", /* 338 */
|
"option '%c' should be handled in the switch", /* 338 */
|
||||||
"option '%c' should be listed in the options string", /* 339 */
|
"option '%c' should be listed in the options string", /* 339 */
|
||||||
|
"initialization with '[a...b]' is a GNU extension", /* 340 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user