Tue Jul 11 20:54:23 2023 UTC ()
lint: update wording in diagnostic for C99


(rillig)
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl_enum_c90.c
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_054.c
diff -r1.452 -r1.453 src/usr.bin/xlint/lint1/cgram.y
diff -r1.210 -r1.211 src/usr.bin/xlint/lint1/err.c
diff -r1.184 -r1.185 src/usr.bin/xlint/lint1/lint1.h

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl_enum_c90.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/decl_enum_c90.c 2022/06/17 18:54:53 1.2
+++ src/tests/usr.bin/xlint/lint1/decl_enum_c90.c 2023/07/11 20:54:23 1.3
@@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
1/* $NetBSD: decl_enum_c90.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ 1/* $NetBSD: decl_enum_c90.c,v 1.3 2023/07/11 20:54:23 rillig Exp $ */
2# 3 "decl_enum_c90.c" 2# 3 "decl_enum_c90.c"
3 3
4/* 4/*
5 * Tests for enum declarations in C90 mode. 5 * Tests for enum declarations in C90 mode.
6 */ 6 */
7 7
8/* lint1-flags: -sw */ 8/* lint1-flags: -sw */
9 9
10enum { 10enum {
11 A, 11 A,
12}; 12};
13/* expect-1: error: trailing ',' prohibited in enum declaration [54] */ 13/* expect-1: error: trailing ',' in enum declaration requires C99 or later [54] */

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_054.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_054.c 2022/04/16 09:22:25 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_054.c 2023/07/11 20:54:23 1.5
@@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
1/* $NetBSD: msg_054.c,v 1.4 2022/04/16 09:22:25 rillig Exp $ */ 1/* $NetBSD: msg_054.c,v 1.5 2023/07/11 20:54:23 rillig Exp $ */
2# 3 "msg_054.c" 2# 3 "msg_054.c"
3 3
4/* Test for message: trailing ',' prohibited in enum declaration [54] */ 4/* Test for message: trailing ',' in enum declaration requires C99 or later [54] */
5 5
6/* lint1-flags: -sw */ 6/* lint1-flags: -sw */
7 7
8enum color { 8enum color {
9 RED, 9 RED,
10 GREEN, 10 GREEN,
11 BLUE, 11 BLUE,
12}; 12};
13/* expect-1: error: trailing ',' prohibited in enum declaration [54] */ 13/* expect-1: error: trailing ',' in enum declaration requires C99 or later [54] */

cvs diff -r1.452 -r1.453 src/usr.bin/xlint/lint1/cgram.y (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2023/07/10 19:58:47 1.452
+++ src/usr.bin/xlint/lint1/cgram.y 2023/07/11 20:54:23 1.453
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.452 2023/07/10 19:58:47 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.453 2023/07/11 20:54:23 rillig Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) 37#if defined(__RCSID)
38__RCSID("$NetBSD: cgram.y,v 1.452 2023/07/10 19:58:47 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.453 2023/07/11 20:54:23 rillig Exp $");
39#endif 39#endif
40 40
41#include <limits.h> 41#include <limits.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <string.h> 43#include <string.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48 48
49/* 49/*
50 * Contains the level of current declaration, used for symbol table entries. 50 * Contains the level of current declaration, used for symbol table entries.
51 * 0 is the top-level, > 0 is inside a function body. 51 * 0 is the top-level, > 0 is inside a function body.
@@ -1156,30 +1156,30 @@ enum_declaration: /* helper for C99 6.7 @@ -1156,30 +1156,30 @@ enum_declaration: /* helper for C99 6.7
1156 ; 1156 ;
1157 1157
1158enum_decl_lbrace: /* helper for C99 6.7.2.2 */ 1158enum_decl_lbrace: /* helper for C99 6.7.2.2 */
1159 T_LBRACE { 1159 T_LBRACE {
1160 set_symtyp(FVFT); 1160 set_symtyp(FVFT);
1161 enumval = 0; 1161 enumval = 0;
1162 } 1162 }
1163 ; 1163 ;
1164 1164
1165enums_with_opt_comma: /* helper for C99 6.7.2.2 */ 1165enums_with_opt_comma: /* helper for C99 6.7.2.2 */
1166 enumerator_list 1166 enumerator_list
1167 | enumerator_list T_COMMA { 1167 | enumerator_list T_COMMA {
1168 if (!allow_c99 && !allow_trad) { 1168 if (!allow_c99 && !allow_trad) {
1169 /* trailing ',' prohibited in enum declaration */ 1169 /* trailing ',' in enum declaration requires C99 ... */
1170 error(54); 1170 error(54);
1171 } else { 1171 } else {
1172 /* trailing ',' prohibited in enum declaration */ 1172 /* trailing ',' in enum declaration requires C99 ... */
1173 c99ism(54); 1173 c99ism(54);
1174 } 1174 }
1175 $$ = $1; 1175 $$ = $1;
1176 } 1176 }
1177 ; 1177 ;
1178 1178
1179enumerator_list: /* C99 6.7.2.2 */ 1179enumerator_list: /* C99 6.7.2.2 */
1180 enumerator 1180 enumerator
1181 | enumerator_list T_COMMA enumerator { 1181 | enumerator_list T_COMMA enumerator {
1182 $$ = concat_symbols($1, $3); 1182 $$ = concat_symbols($1, $3);
1183 } 1183 }
1184 | error { 1184 | error {
1185 $$ = NULL; 1185 $$ = NULL;

cvs diff -r1.210 -r1.211 src/usr.bin/xlint/lint1/err.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/err.c 2023/07/10 19:58:47 1.210
+++ src/usr.bin/xlint/lint1/err.c 2023/07/11 20:54:23 1.211
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: err.c,v 1.210 2023/07/10 19:58:47 rillig Exp $ */ 1/* $NetBSD: err.c,v 1.211 2023/07/11 20:54:23 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) 39#if defined(__RCSID)
40__RCSID("$NetBSD: err.c,v 1.210 2023/07/10 19:58:47 rillig Exp $"); 40__RCSID("$NetBSD: err.c,v 1.211 2023/07/11 20:54:23 rillig Exp $");
41#endif 41#endif
42 42
43#include <limits.h> 43#include <limits.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <string.h> 46#include <string.h>
47 47
48#include "lint1.h" 48#include "lint1.h"
49 49
50bool seen_error; 50bool seen_error;
51bool seen_warning; 51bool seen_warning;
52 52
53/* number of syntax errors */ 53/* number of syntax errors */
@@ -99,27 +99,27 @@ static const char *const msgs[] = { @@ -99,27 +99,27 @@ static const char *const msgs[] = {
99 "bit-field in union is very unusual", /* 41 */ 99 "bit-field in union is very unusual", /* 41 */
100 "forward reference to enum type", /* 42 */ 100 "forward reference to enum type", /* 42 */
101 "redefinition of '%s' hides earlier one", /* 43 */ 101 "redefinition of '%s' hides earlier one", /* 43 */
102 "declaration of '%s %s' introduces new type in ANSI C", /* 44 */ 102 "declaration of '%s %s' introduces new type in ANSI C", /* 44 */
103 "base type is really '%s %s'", /* 45 */ 103 "base type is really '%s %s'", /* 45 */
104 "%s tag '%s' redeclared as %s", /* 46 */ 104 "%s tag '%s' redeclared as %s", /* 46 */
105 "zero sized %s is a C99 feature", /* 47 */ 105 "zero sized %s is a C99 feature", /* 47 */
106 "enumeration value '%s' overflows", /* 48 */ 106 "enumeration value '%s' overflows", /* 48 */
107 "anonymous struct/union members is a C11 feature", /* 49 */ 107 "anonymous struct/union members is a C11 feature", /* 49 */
108 "parameter '%s' has function type, should be pointer", /* 50 */ 108 "parameter '%s' has function type, should be pointer", /* 50 */
109 "parameter mismatch: %d declared, %d defined", /* 51 */ 109 "parameter mismatch: %d declared, %d defined", /* 51 */
110 "cannot initialize parameter '%s'", /* 52 */ 110 "cannot initialize parameter '%s'", /* 52 */
111 "declared argument '%s' is missing", /* 53 */ 111 "declared argument '%s' is missing", /* 53 */
112 "trailing ',' prohibited in enum declaration", /* 54 */ 112 "trailing ',' in enum declaration requires C99 or later", /* 54 */
113 "integral constant expression expected", /* 55 */ 113 "integral constant expression expected", /* 55 */
114 "integral constant too large", /* 56 */ 114 "integral constant too large", /* 56 */
115 "enumeration constant '%s' hides parameter", /* 57 */ 115 "enumeration constant '%s' hides parameter", /* 57 */
116 "type of '%s' does not match prototype", /* 58 */ 116 "type of '%s' does not match prototype", /* 58 */
117 "formal parameter #%d lacks name", /* 59 */ 117 "formal parameter #%d lacks name", /* 59 */
118 "void must be sole parameter", /* 60 */ 118 "void must be sole parameter", /* 60 */
119 "void parameter '%s' cannot have name", /* 61 */ 119 "void parameter '%s' cannot have name", /* 61 */
120 "function prototype parameters must have types", /* 62 */ 120 "function prototype parameters must have types", /* 62 */
121 "prototype does not match old-style definition", /* 63 */ 121 "prototype does not match old-style definition", /* 63 */
122 "()-less function definition", /* 64 */ 122 "()-less function definition", /* 64 */
123 "'%s' has no named members", /* 65 */ 123 "'%s' has no named members", /* 65 */
124 "", /* 66 */ 124 "", /* 66 */
125 "cannot return incomplete type", /* 67 */ 125 "cannot return incomplete type", /* 67 */

cvs diff -r1.184 -r1.185 src/usr.bin/xlint/lint1/lint1.h (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lint1.h 2023/07/10 19:47:12 1.184
+++ src/usr.bin/xlint/lint1/lint1.h 2023/07/11 20:54:23 1.185
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint1.h,v 1.184 2023/07/10 19:47:12 rillig Exp $ */ 1/* $NetBSD: lint1.h,v 1.185 2023/07/11 20:54:23 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -477,32 +477,38 @@ check_printf(const char *fmt, ...) @@ -477,32 +477,38 @@ check_printf(const char *fmt, ...)
477 wrap_check_printf_at(message_at, msgid, pos, ##args) 477 wrap_check_printf_at(message_at, msgid, pos, ##args)
478 478
479# define wrap_check_printf(func, cond, msgid, args...) \ 479# define wrap_check_printf(func, cond, msgid, args...) \
480 ({ \ 480 ({ \
481 if (/* CONSTCOND */cond) \ 481 if (/* CONSTCOND */cond) \
482 debug_step("%s:%d: %s %d '%s' in %s", \ 482 debug_step("%s:%d: %s %d '%s' in %s", \
483 __FILE__, __LINE__, #func, msgid, \ 483 __FILE__, __LINE__, #func, msgid, \
484 __CONCAT(MSG_, msgid), __func__); \ 484 __CONCAT(MSG_, msgid), __func__); \
485 check_printf(__CONCAT(MSG_, msgid), ##args); \ 485 check_printf(__CONCAT(MSG_, msgid), ##args); \
486 (func)(msgid, ##args); \ 486 (func)(msgid, ##args); \
487 /* LINTED 129 */ \ 487 /* LINTED 129 */ \
488 }) 488 })
489 489
490# define error(msgid, args...) wrap_check_printf(error, true, msgid, ##args) 490# define error(msgid, args...) wrap_check_printf(error, \
491# define warning(msgid, args...) wrap_check_printf(warning, true, msgid, ##args) 491 true, msgid, ##args)
492# define gnuism(msgid, args...) wrap_check_printf(gnuism, !allow_gcc || (!allow_trad && !allow_c99), msgid, ##args) 492# define warning(msgid, args...) wrap_check_printf(warning, \
493# define c99ism(msgid, args...) wrap_check_printf(c99ism, !allow_c99 && (!allow_gcc || !allow_trad), msgid, ##args) 493 true, msgid, ##args)
494# define c11ism(msgid, args...) wrap_check_printf(c11ism, !allow_c11 && !allow_gcc, msgid, ##args) 494# define gnuism(msgid, args...) wrap_check_printf(gnuism, \
495# define c23ism(msgid, args...) wrap_check_printf(c23ism, !allow_c23, msgid, ##args) 495 !allow_gcc || (!allow_trad && !allow_c99), msgid, ##args)
 496# define c99ism(msgid, args...) wrap_check_printf(c99ism, \
 497 !allow_c99 && (!allow_gcc || !allow_trad), msgid, ##args)
 498# define c11ism(msgid, args...) wrap_check_printf(c11ism, \
 499 !allow_c11 && !allow_gcc, msgid, ##args)
 500# define c23ism(msgid, args...) wrap_check_printf(c23ism, \
 501 !allow_c23, msgid, ##args)
496#endif 502#endif
497 503
498#ifdef DEBUG 504#ifdef DEBUG
499# define query_message(query_id, args...) \ 505# define query_message(query_id, args...) \
500 do { \ 506 do { \
501 debug_step("%s:%d: query %d '%s' in %s", \ 507 debug_step("%s:%d: query %d '%s' in %s", \
502 __FILE__, __LINE__, \ 508 __FILE__, __LINE__, \
503 query_id, __CONCAT(MSG_Q, query_id), __func__); \ 509 query_id, __CONCAT(MSG_Q, query_id), __func__); \
504 check_printf(__CONCAT(MSG_Q, query_id), ##args); \ 510 check_printf(__CONCAT(MSG_Q, query_id), ##args); \
505 (query_message)(query_id, ##args); \ 511 (query_message)(query_id, ##args); \
506 } while (false) 512 } while (false)
507#else 513#else
508# define query_message(...) \ 514# define query_message(...) \