lint: clean updiff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lang_level_c99.c
(rillig)
--- src/tests/usr.bin/xlint/lint1/lang_level_c99.c 2023/08/06 19:44:50 1.2
+++ src/tests/usr.bin/xlint/lint1/lang_level_c99.c 2024/03/28 21:04:48 1.3
@@ -1,26 +1,31 @@ | @@ -1,26 +1,31 @@ | |||
1 | /* $NetBSD: lang_level_c99.c,v 1.2 2023/08/06 19:44:50 rillig Exp $ */ | 1 | /* $NetBSD: lang_level_c99.c,v 1.3 2024/03/28 21:04:48 rillig Exp $ */ | |
2 | # 3 "lang_level_c99.c" | 2 | # 3 "lang_level_c99.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests that are specific to the C99 language level, in particular, features | 5 | * Tests that are specific to the C99 language level, in particular: | |
6 | * that were added in C99. | |||
7 | * | 6 | * | |
8 | * In the below comments, [-] means unsupported and [x] means supported. | 7 | * * syntax elements that were added in C99 | |
8 | * * lint diagnostics that differ between the C90 and C99 language levels | |||
9 | * * lint diagnostics that differ between the C99 and C11 language levels | |||
9 | */ | 10 | */ | |
10 | 11 | |||
11 | /* lint1-flags: -S -w -X 351 */ | 12 | /* lint1-flags: -S -w -X 351 */ | |
12 | 13 | |||
13 | /* C99 Foreword */ | 14 | /* | |
15 | * Features that were added in the C99 standard, as listed in the C99 foreword. | |||
16 | * | |||
17 | * In the below comments, [-] means unsupported and [x] means supported. | |||
18 | */ | |||
14 | 19 | |||
15 | // [-] restricted character set support via digraphs and <iso646.h> | 20 | // [-] restricted character set support via digraphs and <iso646.h> | |
16 | // | 21 | // | |
17 | // Lint neither parses digraphs nor trigraphs. | 22 | // Lint neither parses digraphs nor trigraphs. | |
18 | 23 | |||
19 | // [x] wide character library support in <wchar.h> and <wctype.h> | 24 | // [x] wide character library support in <wchar.h> and <wctype.h> | |
20 | // | 25 | // | |
21 | // On all supported platforms, 'wchar_t' == 'int'. | 26 | // On all supported platforms, 'wchar_t' == 'int'. | |
22 | 27 | |||
23 | const int wide_string[] = L"wide"; | 28 | const int wide_string[] = L"wide"; | |
24 | 29 | |||
25 | // [x] more precise aliasing rules via effective type | 30 | // [x] more precise aliasing rules via effective type | |
26 | // | 31 | // |
--- src/usr.bin/xlint/lint1/README.md 2024/03/09 13:54:47 1.16
+++ src/usr.bin/xlint/lint1/README.md 2024/03/28 21:04:48 1.17
@@ -1,25 +1,25 @@ | @@ -1,25 +1,25 @@ | |||
1 | [//]: # ($NetBSD: README.md,v 1.16 2024/03/09 13:54:47 rillig Exp $) | 1 | [//]: # ($NetBSD: README.md,v 1.17 2024/03/28 21:04:48 rillig Exp $) | |
2 | 2 | |||
3 | # Introduction | 3 | # Introduction | |
4 | 4 | |||
5 | Lint1 analyzes a single translation unit of C code. | 5 | Lint1 analyzes a single translation unit of C code. | |
6 | 6 | |||
7 | * It reads the output of the C preprocessor, retaining the comments. | 7 | * It reads the output of the C preprocessor, retaining the comments. | |
8 | * The lexer in `scan.l` and `lex.c` splits the input into tokens. | 8 | * The lexer in `scan.l` and `lex.c` splits the input into tokens. | |
9 | * The parser in `cgram.y` creates types and expressions from the tokens. | 9 | * The parser in `cgram.y` creates types and expressions from the tokens. | |
10 | * It checks declarations in `decl.c`. | 10 | * The checks for declarations are in `decl.c`. | |
11 | * It checks initializations in `init.c`. | 11 | * The checks for initializations are in `init.c`. | |
12 | * It checks types and expressions in `tree.c`. | 12 | * The checks for types and expressions are in `tree.c`. | |
13 | 13 | |||
14 | To see how a specific lint message is triggered, read the corresponding unit | 14 | To see how a specific lint message is triggered, read the corresponding unit | |
15 | test in `tests/usr.bin/xlint/lint1/msg_???.c`. | 15 | test in `tests/usr.bin/xlint/lint1/msg_???.c`. | |
16 | 16 | |||
17 | # Features | 17 | # Features | |
18 | 18 | |||
19 | ## Type checking | 19 | ## Type checking | |
20 | 20 | |||
21 | Lint has stricter type checking than most C compilers. | 21 | Lint has stricter type checking than most C compilers. | |
22 | 22 | |||
23 | In _strict bool mode_, lint treats `bool` as a type that is incompatible with | 23 | In _strict bool mode_, lint treats `bool` as a type that is incompatible with | |
24 | other scalar types, like in C#, Go, Java. | 24 | other scalar types, like in C#, Go, Java. | |
25 | See the test `d_c99_bool_strict.c` for details. | 25 | See the test `d_c99_bool_strict.c` for details. | |
@@ -38,30 +38,31 @@ See the test `msg_193.c` for examples. | @@ -38,30 +38,31 @@ See the test `msg_193.c` for examples. | |||
38 | 38 | |||
39 | Lint tries to continue parsing and checking even after seeing errors. | 39 | Lint tries to continue parsing and checking even after seeing errors. | |
40 | This part of lint is not robust though, so expect some crashes here, | 40 | This part of lint is not robust though, so expect some crashes here, | |
41 | as variables may not be properly initialized or be null pointers. | 41 | as variables may not be properly initialized or be null pointers. | |
42 | The cleanup after handling a parse error is often incomplete. | 42 | The cleanup after handling a parse error is often incomplete. | |
43 | 43 | |||
44 | ## Configurable diagnostic messages | 44 | ## Configurable diagnostic messages | |
45 | 45 | |||
46 | Whether lint prints a message and whether each message is an error, a warning | 46 | Whether lint prints a message and whether each message is an error, a warning | |
47 | or just informational depends on several things: | 47 | or just informational depends on several things: | |
48 | 48 | |||
49 | * The language level, with its possible values: | 49 | * The language level, with its possible values: | |
50 | * traditional C (`-t`) | 50 | * traditional C (`-t`) | |
51 | * migration from traditional C and C90 (default) | 51 | * migration from traditional C to C90 (default) | |
52 | * C90 (`-s`) | 52 | * C90 (`-s`) | |
53 | * C99 (`-S`) | 53 | * C99 (`-S`) | |
54 | * C11 (`-Ac11`) | 54 | * C11 (`-Ac11`) | |
55 | * C23 (`-Ac23`) | |||
55 | * In GCC mode (`-g`), lint allows several GNU extensions, | 56 | * In GCC mode (`-g`), lint allows several GNU extensions, | |
56 | reducing the amount of printed messages. | 57 | reducing the amount of printed messages. | |
57 | * In strict bool mode (`-T`), lint issues errors when `bool` is mixed with | 58 | * In strict bool mode (`-T`), lint issues errors when `bool` is mixed with | |
58 | other scalar types, reusing the existing messages 107 and 211, while also | 59 | other scalar types, reusing the existing messages 107 and 211, while also | |
59 | defining new messages that are specific to strict bool mode. | 60 | defining new messages that are specific to strict bool mode. | |
60 | * The option `-a` performs the check for lossy conversions from large integer | 61 | * The option `-a` performs the check for lossy conversions from large integer | |
61 | types, the option `-aa` extends this check to small integer types as well, | 62 | types, the option `-aa` extends this check to small integer types as well, | |
62 | reusing the same message ID. | 63 | reusing the same message ID. | |
63 | * The option `-X` suppresses arbitrary messages by their message ID. | 64 | * The option `-X` suppresses arbitrary messages by their message ID. | |
64 | * The option `-q` enables additional queries that are not suitable as regular | 65 | * The option `-q` enables additional queries that are not suitable as regular | |
65 | warnings but may be interesting to look at on a case-by-case basis. | 66 | warnings but may be interesting to look at on a case-by-case basis. | |
66 | 67 | |||
67 | # Limitations | 68 | # Limitations |
--- src/usr.bin/xlint/lint1/err.c 2024/03/27 19:28:20 1.234
+++ src/usr.bin/xlint/lint1/err.c 2024/03/28 21:04:48 1.235
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: err.c,v 1.234 2024/03/27 19:28:20 rillig Exp $ */ | 1 | /* $NetBSD: err.c,v 1.235 2024/03/28 21:04:48 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.234 2024/03/27 19:28:20 rillig Exp $"); | 40 | __RCSID("$NetBSD: err.c,v 1.235 2024/03/28 21:04:48 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 | |||
50 | bool seen_error; | 50 | bool seen_error; | |
51 | bool seen_warning; | 51 | bool seen_warning; | |
52 | 52 | |||
53 | /* number of syntax errors */ | 53 | /* number of syntax errors */ | |
@@ -729,27 +729,27 @@ static const char *queries[] = { | @@ -729,27 +729,27 @@ static const char *queries[] = { | |||
729 | "pointer addition has integer on the left-hand side", // Q5 | 729 | "pointer addition has integer on the left-hand side", // Q5 | |
730 | "no-op cast from '%s' to '%s'", // Q6 | 730 | "no-op cast from '%s' to '%s'", // Q6 | |
731 | "redundant cast from '%s' to '%s' before assignment", // Q7 | 731 | "redundant cast from '%s' to '%s' before assignment", // Q7 | |
732 | "octal number '%.*s'", // Q8 | 732 | "octal number '%.*s'", // Q8 | |
733 | "parenthesized return value", // Q9 | 733 | "parenthesized return value", // Q9 | |
734 | "chained assignment with '%s' and '%s'", // Q10 | 734 | "chained assignment with '%s' and '%s'", // Q10 | |
735 | "static variable '%s' in function", // Q11 | 735 | "static variable '%s' in function", // Q11 | |
736 | "comma operator with types '%s' and '%s'", // Q12 | 736 | "comma operator with types '%s' and '%s'", // Q12 | |
737 | "redundant 'extern' in function declaration of '%s'", // Q13 | 737 | "redundant 'extern' in function declaration of '%s'", // Q13 | |
738 | "comparison '%s' of 'char' with plain integer %d", // Q14 | 738 | "comparison '%s' of 'char' with plain integer %d", // Q14 | |
739 | "implicit conversion from integer 0 to pointer '%s'", // Q15 | 739 | "implicit conversion from integer 0 to pointer '%s'", // Q15 | |
740 | "'%s' was declared 'static', now non-'static'", // Q16 | 740 | "'%s' was declared 'static', now non-'static'", // Q16 | |
741 | "invisible character U+%04X in %s", // Q17 | 741 | "invisible character U+%04X in %s", // Q17 | |
742 | "const automatic variable '%s'", // Q18 | 742 | "const automatic variable '%s'", // Q18 | |
743 | }; | 743 | }; | |
744 | 744 | |||
745 | bool any_query_enabled; /* for optimizing non-query scenarios */ | 745 | bool any_query_enabled; /* for optimizing non-query scenarios */ | |
746 | bool is_query_enabled[sizeof(queries) / sizeof(queries[0])]; | 746 | bool is_query_enabled[sizeof(queries) / sizeof(queries[0])]; | |
747 | 747 | |||
748 | void | 748 | void | |
749 | (query_message)(int query_id, ...) | 749 | (query_message)(int query_id, ...) | |
750 | { | 750 | { | |
751 | 751 | |||
752 | if (!is_query_enabled[query_id]) | 752 | if (!is_query_enabled[query_id]) | |
753 | return; | 753 | return; | |
754 | 754 | |||
755 | va_list ap; | 755 | va_list ap; |
--- src/usr.bin/xlint/lint1/externs1.h 2024/03/09 10:41:11 1.219
+++ src/usr.bin/xlint/lint1/externs1.h 2024/03/28 21:04:48 1.220
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: externs1.h,v 1.219 2024/03/09 10:41:11 rillig Exp $ */ | 1 | /* $NetBSD: externs1.h,v 1.220 2024/03/28 21:04:48 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. | |
@@ -26,65 +26,65 @@ | @@ -26,65 +26,65 @@ | |||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
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 | #include <signal.h> | 34 | #include <signal.h> | |
35 | 35 | |||
36 | /* | 36 | /* | |
37 | * main1.c | 37 | * main1.c | |
38 | */ | 38 | */ | |
39 | extern bool Fflag; | |||
40 | extern bool Pflag; | |||
41 | extern bool Tflag; | |||
39 | extern int aflag; | 42 | extern int aflag; | |
40 | extern bool bflag; | 43 | extern bool bflag; | |
41 | extern bool cflag; | 44 | extern bool cflag; | |
42 | extern bool eflag; | 45 | extern bool eflag; | |
43 | extern bool Fflag; | |||
44 | extern bool hflag; | 46 | extern bool hflag; | |
45 | extern bool pflag; | 47 | extern bool pflag; | |
46 | extern bool rflag; | 48 | extern bool rflag; | |
47 | extern bool uflag; | 49 | extern bool uflag; | |
48 | extern bool vflag; | 50 | extern bool vflag; | |
49 | extern bool yflag; | |||
50 | extern bool wflag; | 51 | extern bool wflag; | |
52 | extern bool yflag; | |||
51 | extern bool zflag; | 53 | extern bool zflag; | |
52 | extern bool Tflag; | |||
53 | extern bool Pflag; | |||
54 | 54 | |||
55 | extern bool allow_trad; | 55 | extern bool allow_trad; | |
56 | extern bool allow_c90; | 56 | extern bool allow_c90; | |
57 | extern bool allow_c99; | 57 | extern bool allow_c99; | |
58 | extern bool allow_c11; | 58 | extern bool allow_c11; | |
59 | extern bool allow_c23; | 59 | extern bool allow_c23; | |
60 | extern bool allow_gcc; | 60 | extern bool allow_gcc; | |
61 | 61 | |||
62 | extern sig_atomic_t fpe; | 62 | extern sig_atomic_t fpe; | |
63 | 63 | |||
64 | void norecover(void); | 64 | void norecover(void); | |
65 | 65 | |||
66 | /* | 66 | /* | |
67 | * cgram.y | 67 | * cgram.y | |
68 | */ | 68 | */ | |
69 | extern int block_level; | 69 | extern int block_level; | |
70 | extern size_t mem_block_level; | 70 | extern size_t mem_block_level; | |
71 | extern int yydebug; | 71 | extern int yydebug; | |
72 | 72 | |||
73 | int yyerror(const char *); | 73 | int yyerror(const char *); | |
74 | int yyparse(void); | 74 | int yyparse(void); | |
75 | 75 | |||
76 | /* | 76 | /* | |
77 | * scan.l | 77 | * lex.c | |
78 | */ | 78 | */ | |
79 | extern bool in_gcc_attribute; | 79 | extern bool in_gcc_attribute; | |
80 | extern pos_t curr_pos; | 80 | extern pos_t curr_pos; | |
81 | extern pos_t csrc_pos; | 81 | extern pos_t csrc_pos; | |
82 | extern bool in_system_header; | 82 | extern bool in_system_header; | |
83 | extern symbol_kind sym_kind; | 83 | extern symbol_kind sym_kind; | |
84 | extern FILE *yyin; | 84 | extern FILE *yyin; | |
85 | 85 | |||
86 | void init_lex(void); | 86 | void init_lex(void); | |
87 | int64_t convert_integer(int64_t, tspec_t, unsigned int); | 87 | int64_t convert_integer(int64_t, tspec_t, unsigned int); | |
88 | void clear_warn_flags(void); | 88 | void clear_warn_flags(void); | |
89 | sym_t *getsym(sbuf_t *); | 89 | sym_t *getsym(sbuf_t *); | |
90 | void clean_up_after_error(void); | 90 | void clean_up_after_error(void); |