Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/xlint lint: add initial support for C23
details: https://anonhg.NetBSD.org/src/rev/4a712435a0ab
branches: trunk
changeset: 377240:4a712435a0ab
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 02 23:40:23 2023 +0000
description:
lint: add initial support for C23
Required by xsrc/external/mit/MesaLib.old, brw_eu_validate.c, which
initializes a struct using empty braces: 'return (struct string){};'.
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/t_usage.sh | 8 ++++----
usr.bin/xlint/lint1/cgram.y | 16 +++++++++++++---
usr.bin/xlint/lint1/check-msgs.lua | 3 ++-
usr.bin/xlint/lint1/err.c | 17 +++++++++++++++--
usr.bin/xlint/lint1/externs1.h | 4 +++-
usr.bin/xlint/lint1/lint1.h | 3 ++-
usr.bin/xlint/lint1/main1.c | 17 ++++++++++++++---
usr.bin/xlint/xlint/lint.1 | 12 +++++++-----
9 files changed, 63 insertions(+), 21 deletions(-)
diffs (truncated from 324 to 300 lines):
diff -r 84b37bdf862c -r 4a712435a0ab distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jul 02 22:56:13 2023 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1271 2023/06/16 23:51:31 rillig Exp $
+# $NetBSD: mi,v 1.1272 2023/07/02 23:40:23 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6509,6 +6509,7 @@
./usr/tests/usr.bin/xlint/lint1/c11_atomic.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.exp tests-obsolete obsolete,atf
+./usr/tests/usr.bin/xlint/lint1/c23.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c90.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c90.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/c99_atomic.c tests-usr.bin-tests compattestfile,atf
@@ -7432,6 +7433,7 @@
./usr/tests/usr.bin/xlint/lint1/msg_350.c tests-usr.bin-tests compattestfile,atf
./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/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
diff -r 84b37bdf862c -r 4a712435a0ab tests/usr.bin/xlint/lint1/t_usage.sh
--- a/tests/usr.bin/xlint/lint1/t_usage.sh Sun Jul 02 22:56:13 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/t_usage.sh Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_usage.sh,v 1.9 2023/06/30 08:45:22 rillig Exp $
+# $NetBSD: t_usage.sh,v 1.10 2023/07/02 23:40:23 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 352 code.c /dev/null
+ "$lint1" -X 353 code.c /dev/null
# Larger than the largest known message.
atf_check \
-s 'exit:1' \
- -e "inline:lint1: invalid message ID '353'\n" \
- "$lint1" -X 353 code.c /dev/null
+ -e "inline:lint1: invalid message ID '354'\n" \
+ "$lint1" -X 354 code.c /dev/null
# Whitespace is not allowed before a message ID.
atf_check \
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jul 02 23:40:23 2023 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.445 2023/07/02 22:56:13 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.446 2023/07/02 23:40:23 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.445 2023/07/02 22:56:13 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.446 2023/07/02 23:40:23 rillig Exp $");
#endif
#include <limits.h>
@@ -459,7 +459,7 @@ postfix_expression:
sym_t *tmp = mktempsym($2);
begin_initialization(tmp);
cgram_declare(tmp, true, NULL);
- } init_lbrace initializer_list comma_opt init_rbrace {
+ } braced_initializer {
if (!allow_c99)
/* compound literals are a C99/GCC extension */
gnuism(319);
@@ -1519,6 +1519,16 @@ parameter_declaration:
}
;
+braced_initializer:
+ /* K&R ---, C90 ---, C99 ---, C11 ---, C23 6.7.10 */
+ init_lbrace init_rbrace {
+ /* empty initializer braces require C23 or later */
+ c23ism(353);
+ }
+ /* K&R ---, C90 ---, C99 6.7.8, C11 6.7.9, C23 6.7.10 */
+ | init_lbrace initializer_list comma_opt init_rbrace
+ ;
+
initializer: /* C99 6.7.8 "Initialization" */
assignment_expression {
init_expr($1);
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/check-msgs.lua
--- a/usr.bin/xlint/lint1/check-msgs.lua Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/check-msgs.lua Sun Jul 02 23:40:23 2023 +0000
@@ -1,5 +1,5 @@
#! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.17 2022/07/05 22:50:41 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.18 2023/07/02 23:40:23 rillig Exp $
--[[
@@ -69,6 +69,7 @@ local message_prefix = {
query_message = "Q",
c99ism = "",
c11ism = "",
+ c23ism = "",
gnuism = "",
}
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.203 2023/06/30 08:45:22 rillig Exp $ */
+/* $NetBSD: err.c,v 1.204 2023/07/02 23:40:23 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.203 2023/06/30 08:45:22 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.204 2023/07/02 23:40:23 rillig Exp $");
#endif
#include <limits.h>
@@ -408,6 +408,7 @@ static const char *const msgs[] = {
"'_Atomic' requires C11 or later", /* 350 */
"missing%s header declaration for '%s'", /* 351 */
"nested 'extern' declaration of '%s'", /* 352 */
+ "empty initializer braces require C23 or later", /* 353 */
};
static bool is_suppressed[sizeof(msgs) / sizeof(msgs[0])];
@@ -677,6 +678,18 @@ void
va_end(ap);
}
+void
+(c23ism)(int msgid, ...)
+{
+ va_list ap;
+
+ if (allow_c23)
+ return;
+ va_start(ap, msgid);
+ verror_at(msgid, &curr_pos, ap);
+ va_end(ap);
+}
+
bool
(gnuism)(int msgid, ...)
{
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.187 2023/07/02 18:14:44 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.188 2023/07/02 23:40:23 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -56,6 +56,7 @@ extern bool allow_trad;
extern bool allow_c90;
extern bool allow_c99;
extern bool allow_c11;
+extern bool allow_c23;
extern bool allow_gcc;
extern sig_atomic_t fpe;
@@ -168,6 +169,7 @@ void warning(int, ...);
bool gnuism(int, ...);
void c99ism(int, ...);
void c11ism(int, ...);
+void c23ism(int, ...);
void assert_failed(const char *, int, const char *, const char *)
__attribute__((__noreturn__));
void update_location(const char *, int, bool, bool);
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.178 2023/07/02 18:28:15 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.179 2023/07/02 23:40:23 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -492,6 +492,7 @@ check_printf(const char *fmt, ...)
# define gnuism(msgid, args...) wrap_check_printf(gnuism, !allow_gcc || (!allow_trad && !allow_c99), msgid, ##args)
# define c99ism(msgid, args...) wrap_check_printf(c99ism, !allow_c99 && (!allow_gcc || !allow_trad), msgid, ##args)
# define c11ism(msgid, args...) wrap_check_printf(c11ism, !allow_c11 && !allow_gcc, msgid, ##args)
+# define c23ism(msgid, args...) wrap_check_printf(c23ism, !allow_c23, msgid, ##args)
#endif
#ifdef DEBUG
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/lint1/main1.c Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.66 2023/01/13 19:41:50 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.67 2023/07/02 23:40:23 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: main1.c,v 1.66 2023/01/13 19:41:50 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.67 2023/07/02 23:40:23 rillig Exp $");
#endif
#include <sys/types.h>
@@ -116,6 +116,7 @@ bool allow_trad = true;
bool allow_c90 = true;
bool allow_c99;
bool allow_c11;
+bool allow_c23;
bool allow_gcc;
sig_atomic_t fpe;
@@ -195,12 +196,14 @@ main(int argc, char *argv[])
allow_c90 = true;
allow_c99 = false;
allow_c11 = false;
+ allow_c23 = false;
break;
case 'S':
allow_trad = false;
allow_c90 = true;
allow_c99 = true;
allow_c11 = false;
+ allow_c23 = false;
break;
case 'T': Tflag = true; break;
case 't':
@@ -208,6 +211,7 @@ main(int argc, char *argv[])
allow_c90 = false;
allow_c99 = false;
allow_c11 = false;
+ allow_c23 = false;
break;
case 'u': uflag = false; break;
case 'w': wflag = true; break;
@@ -216,11 +220,18 @@ main(int argc, char *argv[])
case 'z': zflag = false; break;
case 'A':
- if (strcmp(optarg, "c11") == 0) {
+ if (strcmp(optarg, "c23") == 0) {
allow_trad = false;
allow_c90 = true;
allow_c99 = true;
allow_c11 = true;
+ allow_c23 = true;
+ } else if (strcmp(optarg, "c11") == 0) {
+ allow_trad = false;
+ allow_c90 = true;
+ allow_c99 = true;
+ allow_c11 = true;
+ allow_c23 = true;
} else
usage();
break;
diff -r 84b37bdf862c -r 4a712435a0ab usr.bin/xlint/xlint/lint.1
--- a/usr.bin/xlint/xlint/lint.1 Sun Jul 02 22:56:13 2023 +0000
+++ b/usr.bin/xlint/xlint/lint.1 Sun Jul 02 23:40:23 2023 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: lint.1,v 1.59 2023/06/28 13:50:47 rillig Exp $
+.\" $NetBSD: lint.1,v 1.60 2023/07/02 23:40:23 rillig Exp $
.\"
.\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
.\" Copyright (c) 1994, 1995 Jochen Pohl
@@ -30,7 +30,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 28, 2023
+.Dd July 3, 2023
.Dt LINT 1
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Nm
.Op Fl abceFgHhPprTVvwxz
.Op Fl i | Fl nu
-.Op Fl S | Fl s | Fl t | Fl Ac11
+.Op Fl S | Fl s | Fl t | Fl Ac11 | Fl Ac23
.Op Fl B Ar directory
.Op Fl D Ar name Ns Op =def
.Op Fl d Ar directory
@@ -57,7 +57,7 @@
.Ar
.Nm lint
Home |
Main Index |
Thread Index |
Old Index