Module Name: src Committed By: rillig Date: Thu Aug 3 18:48:42 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: c11.c t_usage.sh src/usr.bin/xlint/lint1: cgram.y err.c Added Files: src/tests/usr.bin/xlint/lint1: msg_354.c msg_355.c Log Message: lint: make '_Static_assert' only available in C11 or C23 mode To generate a diff of this commit: cvs rdiff -u -r1.1283 -r1.1284 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/c11.c cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_354.c \ src/tests/usr.bin/xlint/lint1/msg_355.c cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/t_usage.sh cvs rdiff -u -r1.469 -r1.470 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.215 -r1.216 src/usr.bin/xlint/lint1/err.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1283 src/distrib/sets/lists/tests/mi:1.1284 --- src/distrib/sets/lists/tests/mi:1.1283 Thu Aug 3 13:13:05 2023 +++ src/distrib/sets/lists/tests/mi Thu Aug 3 18:48:42 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1283 2023/08/03 13:13:05 rin Exp $ +# $NetBSD: mi,v 1.1284 2023/08/03 18:48:42 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -7444,6 +7444,8 @@ ./usr/tests/usr.bin/xlint/lint1/msg_351.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_352.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_353.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/msg_354.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/msg_355.c 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-obsolete obsolete,atf ./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/c11.c diff -u src/tests/usr.bin/xlint/lint1/c11.c:1.4 src/tests/usr.bin/xlint/lint1/c11.c:1.5 --- src/tests/usr.bin/xlint/lint1/c11.c:1.4 Fri Jul 28 22:05:44 2023 +++ src/tests/usr.bin/xlint/lint1/c11.c Thu Aug 3 18:48:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: c11.c,v 1.4 2023/07/28 22:05:44 rillig Exp $ */ +/* $NetBSD: c11.c,v 1.5 2023/08/03 18:48:42 rillig Exp $ */ # 3 "c11.c" /* @@ -43,9 +43,10 @@ three_times(void) } -_Static_assert(1 > 0, "string"); -/* XXX: requires C23 or later */ -_Static_assert(1 > 0); +struct static_assert_tag { + _Static_assert(1 > 0, "string"); + int member; +}; // C11 6.7.6.1p3 Index: src/tests/usr.bin/xlint/lint1/t_usage.sh diff -u src/tests/usr.bin/xlint/lint1/t_usage.sh:1.10 src/tests/usr.bin/xlint/lint1/t_usage.sh:1.11 --- src/tests/usr.bin/xlint/lint1/t_usage.sh:1.10 Sun Jul 2 23:40:23 2023 +++ src/tests/usr.bin/xlint/lint1/t_usage.sh Thu Aug 3 18:48:42 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_usage.sh,v 1.10 2023/07/02 23:40:23 rillig Exp $ +# $NetBSD: t_usage.sh,v 1.11 2023/08/03 18:48:42 rillig Exp $ # # Copyright (c) 2023 The NetBSD Foundation, Inc. # All rights reserved. @@ -39,13 +39,13 @@ suppress_messages_body() # The largest known message. atf_check \ - "$lint1" -X 353 code.c /dev/null + "$lint1" -X 355 code.c /dev/null # Larger than the largest known message. atf_check \ -s 'exit:1' \ - -e "inline:lint1: invalid message ID '354'\n" \ - "$lint1" -X 354 code.c /dev/null + -e "inline:lint1: invalid message ID '356'\n" \ + "$lint1" -X 356 code.c /dev/null # Whitespace is not allowed before a message ID. atf_check \ Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.469 src/usr.bin/xlint/lint1/cgram.y:1.470 --- src/usr.bin/xlint/lint1/cgram.y:1.469 Wed Aug 2 21:11:35 2023 +++ src/usr.bin/xlint/lint1/cgram.y Thu Aug 3 18:48:42 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.469 2023/08/02 21:11:35 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.470 2023/08/03 18:48:42 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.469 2023/08/02 21:11:35 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.470 2023/08/03 18:48:42 rillig Exp $"); #endif #include <limits.h> @@ -1695,9 +1695,15 @@ designator: /* C99 6.7.8 "Initializati ; static_assert_declaration: - T_STATIC_ASSERT T_LPAREN - constant_expression T_COMMA T_STRING T_RPAREN T_SEMI /* C11 */ -| T_STATIC_ASSERT T_LPAREN constant_expression T_RPAREN T_SEMI /* C23 */ + T_STATIC_ASSERT T_LPAREN constant_expression T_COMMA T_STRING + T_RPAREN T_SEMI { + /* '_Static_assert' requires C11 or later */ + c11ism(354); + } +| T_STATIC_ASSERT T_LPAREN constant_expression T_RPAREN T_SEMI { + /* '_Static_assert' without message requires C23 or later */ + c23ism(355); + } ; range: Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.215 src/usr.bin/xlint/lint1/err.c:1.216 --- src/usr.bin/xlint/lint1/err.c:1.215 Wed Aug 2 18:51:25 2023 +++ src/usr.bin/xlint/lint1/err.c Thu Aug 3 18:48:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.215 2023/08/02 18:51:25 rillig Exp $ */ +/* $NetBSD: err.c,v 1.216 2023/08/03 18:48:42 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: err.c,v 1.215 2023/08/02 18:51:25 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.216 2023/08/03 18:48:42 rillig Exp $"); #endif #include <limits.h> @@ -409,6 +409,8 @@ static const char *const msgs[] = { "missing%s header declaration for '%s'", /* 351 */ "nested 'extern' declaration of '%s'", /* 352 */ "empty initializer braces require C23 or later", /* 353 */ + "'_Static_assert' requires C11 or later", /* 354 */ + "'_Static_assert' without message requires C23 or later", /* 355 */ }; static bool is_suppressed[sizeof(msgs) / sizeof(msgs[0])]; Added files: Index: src/tests/usr.bin/xlint/lint1/msg_354.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_354.c:1.1 --- /dev/null Thu Aug 3 18:48:42 2023 +++ src/tests/usr.bin/xlint/lint1/msg_354.c Thu Aug 3 18:48:42 2023 @@ -0,0 +1,14 @@ +/* $NetBSD: msg_354.c,v 1.1 2023/08/03 18:48:42 rillig Exp $ */ +# 3 "msg_354.c" + +// Test for message 354: '_Static_assert' requires C11 or later [354] +// +// See also: +// c23.c + +/* lint1-flags: -Sw -X 351 */ + +/* expect+1: error: '_Static_assert' requires C11 or later [354] */ +_Static_assert(1 > 0, "message"); +/* expect+1: error: '_Static_assert' without message requires C23 or later [355] */ +_Static_assert(1 > 0); Index: src/tests/usr.bin/xlint/lint1/msg_355.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_355.c:1.1 --- /dev/null Thu Aug 3 18:48:42 2023 +++ src/tests/usr.bin/xlint/lint1/msg_355.c Thu Aug 3 18:48:42 2023 @@ -0,0 +1,13 @@ +/* $NetBSD: msg_355.c,v 1.1 2023/08/03 18:48:42 rillig Exp $ */ +# 3 "msg_355.c" + +// Test for message 355: '_Static_assert' without message requires C23 or later [355] +// +// See also: +// c23.c + +/* lint1-extra-flags: -Ac11 -X 351 */ + +_Static_assert(1 > 0, "message"); +/* expect+1: error: '_Static_assert' without message requires C23 or later [355] */ +_Static_assert(1 > 0);