lint: revert resolving grammar conflicts for labeled statements Restore the grammar rule for labeled_statement as it was before cgram.y 1.400 from 2022-04-24. This allows labels with attributes again. Fix the wrong interpretation in the tests; the attributes belong to the label, not to the statement. Today in the morning, when I thought that the change in cgram.y 1.400 were innocent, I accidentally ran lint only with the options '-Sw' but forgot the option '-g' for GNU mode. Without that option, the token '__attribute__' is unknown, which unsurprisingly leads to lots of syntax errors, and these didn't change with that commit. The actual change was only visible in GNU mode.diff -r1.1199 -r1.1200 src/distrib/sets/lists/tests/mi
(rillig)
--- src/distrib/sets/lists/tests/mi 2022/04/26 22:48:53 1.1199
+++ src/distrib/sets/lists/tests/mi 2022/04/28 21:38:38 1.1200
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: mi,v 1.1199 2022/04/26 22:48:53 blymn Exp $ | 1 | # $NetBSD: mi,v 1.1200 2022/04/28 21:38:38 rillig Exp $ | |
2 | # | 2 | # | |
3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | 3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | |
4 | # | 4 | # | |
5 | ./etc/mtree/set.tests tests-sys-root | 5 | ./etc/mtree/set.tests tests-sys-root | |
6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir | 6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir | |
7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf | 7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf | |
8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf | 8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf | |
9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf | 9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf | |
10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf | 10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf | |
11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf | 11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf | |
12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete | 12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete | |
13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete | 13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete | |
14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete | 14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete | |
@@ -6495,27 +6495,27 @@ | @@ -6495,27 +6495,27 @@ | |||
6495 | ./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf | 6495 | ./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf | |
6496 | ./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf | 6496 | ./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf | |
6497 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf | 6497 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf | |
6498 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf | 6498 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf | |
6499 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf | 6499 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf | |
6500 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf | 6500 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf | |
6501 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf | 6501 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf | |
6502 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp tests-usr.bin-tests compattestfile,atf | 6502 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp tests-usr.bin-tests compattestfile,atf | |
6503 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c tests-usr.bin-tests compattestfile,atf | 6503 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c tests-usr.bin-tests compattestfile,atf | |
6504 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp tests-usr.bin-tests compattestfile,atf | 6504 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp tests-usr.bin-tests compattestfile,atf | |
6505 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_func.c tests-usr.bin-tests compattestfile,atf | 6505 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_func.c tests-usr.bin-tests compattestfile,atf | |
6506 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_func.exp tests-usr.bin-tests compattestfile,atf | 6506 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_func.exp tests-usr.bin-tests compattestfile,atf | |
6507 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_label.c tests-usr.bin-tests compattestfile,atf | 6507 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_label.c tests-usr.bin-tests compattestfile,atf | |
6508 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_label.exp tests-obsolete obsolete | 6508 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_label.exp tests-usr.bin-tests compattestfile,atf | |
6509 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c tests-usr.bin-tests compattestfile,atf | 6509 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c tests-usr.bin-tests compattestfile,atf | |
6510 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp tests-usr.bin-tests compattestfile,atf | 6510 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp tests-usr.bin-tests compattestfile,atf | |
6511 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_type.c tests-usr.bin-tests compattestfile,atf | 6511 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_type.c tests-usr.bin-tests compattestfile,atf | |
6512 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_type.exp tests-usr.bin-tests compattestfile,atf | 6512 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_type.exp tests-usr.bin-tests compattestfile,atf | |
6513 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.c tests-usr.bin-tests compattestfile,atf | 6513 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.c tests-usr.bin-tests compattestfile,atf | |
6514 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp tests-usr.bin-tests compattestfile,atf | 6514 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp tests-usr.bin-tests compattestfile,atf | |
6515 | ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c tests-usr.bin-tests compattestfile,atf | 6515 | ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c tests-usr.bin-tests compattestfile,atf | |
6516 | ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp tests-usr.bin-tests compattestfile,atf | 6516 | ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp tests-usr.bin-tests compattestfile,atf | |
6517 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.c tests-usr.bin-tests compattestfile,atf | 6517 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.c tests-usr.bin-tests compattestfile,atf | |
6518 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.exp tests-usr.bin-tests compattestfile,atf | 6518 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_alloca.exp tests-usr.bin-tests compattestfile,atf | |
6519 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c tests-usr.bin-tests compattestfile,atf | 6519 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.c tests-usr.bin-tests compattestfile,atf | |
6520 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp tests-usr.bin-tests compattestfile,atf | 6520 | ./usr/tests/usr.bin/xlint/lint1/gcc_builtin_overflow.exp tests-usr.bin-tests compattestfile,atf | |
6521 | ./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.c tests-usr.bin-tests compattestfile,atf | 6521 | ./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.c tests-usr.bin-tests compattestfile,atf |
--- src/tests/usr.bin/xlint/lint1/Makefile 2022/04/16 20:18:52 1.120
+++ src/tests/usr.bin/xlint/lint1/Makefile 2022/04/28 21:38:38 1.121
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile,v 1.120 2022/04/16 20:18:52 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.121 2022/04/28 21:38:38 rillig Exp $ | |
2 | 2 | |||
3 | NOMAN= # defined | 3 | NOMAN= # defined | |
4 | MAX_MESSAGE= 348 # see lint1/err.c | 4 | MAX_MESSAGE= 348 # see lint1/err.c | |
5 | 5 | |||
6 | .include <bsd.own.mk> | 6 | .include <bsd.own.mk> | |
7 | 7 | |||
8 | ARCHSUBDIR!= cd ${NETBSDSRCDIR}/usr.bin/xlint/lint1 && ${MAKE} -v ARCHSUBDIR | 8 | ARCHSUBDIR!= cd ${NETBSDSRCDIR}/usr.bin/xlint/lint1 && ${MAKE} -v ARCHSUBDIR | |
9 | 9 | |||
10 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | 10 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | |
11 | 11 | |||
12 | TESTS_SH= t_integration | 12 | TESTS_SH= t_integration | |
13 | TESTS_SH_SRC_t_integration= archsubdir.sh t_integration.sh | 13 | TESTS_SH_SRC_t_integration= archsubdir.sh t_integration.sh | |
14 | CLEANFILES+= archsubdir.sh | 14 | CLEANFILES+= archsubdir.sh | |
@@ -155,26 +155,27 @@ FILES+= expr_promote_trad.exp-ln | @@ -155,26 +155,27 @@ FILES+= expr_promote_trad.exp-ln | |||
155 | FILES+= expr_range.c | 155 | FILES+= expr_range.c | |
156 | FILES+= expr_range.exp | 156 | FILES+= expr_range.exp | |
157 | FILES+= feat_stacktrace.c | 157 | FILES+= feat_stacktrace.c | |
158 | FILES+= feat_stacktrace.exp | 158 | FILES+= feat_stacktrace.exp | |
159 | FILES+= gcc_attribute.c | 159 | FILES+= gcc_attribute.c | |
160 | FILES+= gcc_attribute.exp | 160 | FILES+= gcc_attribute.exp | |
161 | FILES+= gcc_attribute_aligned.c | 161 | FILES+= gcc_attribute_aligned.c | |
162 | FILES+= gcc_attribute_aligned.exp | 162 | FILES+= gcc_attribute_aligned.exp | |
163 | FILES+= gcc_attribute_enum.c | 163 | FILES+= gcc_attribute_enum.c | |
164 | FILES+= gcc_attribute_enum.exp | 164 | FILES+= gcc_attribute_enum.exp | |
165 | FILES+= gcc_attribute_func.c | 165 | FILES+= gcc_attribute_func.c | |
166 | FILES+= gcc_attribute_func.exp | 166 | FILES+= gcc_attribute_func.exp | |
167 | FILES+= gcc_attribute_label.c | 167 | FILES+= gcc_attribute_label.c | |
168 | FILES+= gcc_attribute_label.exp | |||
168 | FILES+= gcc_attribute_stmt.c | 169 | FILES+= gcc_attribute_stmt.c | |
169 | FILES+= gcc_attribute_stmt.exp | 170 | FILES+= gcc_attribute_stmt.exp | |
170 | FILES+= gcc_attribute_type.c | 171 | FILES+= gcc_attribute_type.c | |
171 | FILES+= gcc_attribute_type.exp | 172 | FILES+= gcc_attribute_type.exp | |
172 | FILES+= gcc_attribute_var.c | 173 | FILES+= gcc_attribute_var.c | |
173 | FILES+= gcc_attribute_var.exp | 174 | FILES+= gcc_attribute_var.exp | |
174 | FILES+= gcc_bit_field_types.c | 175 | FILES+= gcc_bit_field_types.c | |
175 | FILES+= gcc_bit_field_types.exp | 176 | FILES+= gcc_bit_field_types.exp | |
176 | FILES+= gcc_builtin_alloca.c | 177 | FILES+= gcc_builtin_alloca.c | |
177 | FILES+= gcc_builtin_alloca.exp | 178 | FILES+= gcc_builtin_alloca.exp | |
178 | FILES+= gcc_builtin_overflow.c | 179 | FILES+= gcc_builtin_overflow.c | |
179 | FILES+= gcc_builtin_overflow.exp | 180 | FILES+= gcc_builtin_overflow.exp | |
180 | FILES+= gcc_cast_union.c | 181 | FILES+= gcc_cast_union.c |
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_label.c 2021/07/11 19:24:42 1.2
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_label.c 2022/04/28 21:38:38 1.3
@@ -1,25 +1,49 @@ | @@ -1,25 +1,49 @@ | |||
1 | /* $NetBSD: gcc_attribute_label.c,v 1.2 2021/07/11 19:24:42 rillig Exp $ */ | 1 | /* $NetBSD: gcc_attribute_label.c,v 1.3 2022/04/28 21:38:38 rillig Exp $ */ | |
2 | # 3 "gcc_attribute_label.c" | 2 | # 3 "gcc_attribute_label.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the GCC __attribute__ for labels. | 5 | * Tests for the GCC __attribute__ for labels. | |
6 | * | 6 | * | |
7 | * https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html | 7 | * https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void dead(void); | 10 | void dead(void); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test(int i) | 13 | test(int i) | |
14 | { | 14 | { | |
15 | if (i < 1000) | 15 | if (i < 1000) | |
16 | goto hot; | 16 | goto hot; | |
17 | error: | 17 | error: | |
18 | __attribute__((__cold__)); | 18 | __attribute__((__cold__)); | |
19 | dead(); | 19 | dead(); | |
20 | 20 | |||
21 | hot: | 21 | hot: | |
22 | __attribute__((__hot__)); | 22 | __attribute__((__hot__)); | |
23 | if (i < 0) | 23 | if (i < 0) | |
24 | goto error; | 24 | goto error; | |
25 | } | 25 | } | |
26 | ||||
27 | /* GCC allows a label to be marked as (possibly) unused. */ | |||
28 | void | |||
29 | unused_labels(int x) | |||
30 | { | |||
31 | switch (x) { | |||
32 | case 3: | |||
33 | __attribute__((__unused__)) | |||
34 | break; | |||
35 | case 4: | |||
36 | goto label; | |||
37 | label: | |||
38 | __attribute__((__unused__)) | |||
39 | return; | |||
40 | } | |||
41 | ||||
42 | /* | |||
43 | * The GCC attributes may only occur after a label; they cannot occur | |||
44 | * before an arbitrary statement. | |||
45 | */ | |||
46 | __attribute__((__unused__)) | |||
47 | /* expect+1: error: syntax error 'return' [249] */ | |||
48 | return; | |||
49 | } |
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c 2022/04/28 07:10:39 1.2
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c 2022/04/28 21:38:38 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_attribute_stmt.c,v 1.2 2022/04/28 07:10:39 rillig Exp $ */ | 1 | /* $NetBSD: gcc_attribute_stmt.c,v 1.3 2022/04/28 21:38:38 rillig Exp $ */ | |
2 | # 3 "gcc_attribute_stmt.c" | 2 | # 3 "gcc_attribute_stmt.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the GCC __attribute__ for statements. | 5 | * Tests for the GCC __attribute__ for statements. | |
6 | * | 6 | * | |
7 | * https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html | 7 | * https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void println(const char *); | 10 | void println(const char *); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | attribute_fallthrough(int i) | 13 | attribute_fallthrough(int i) | |
14 | { | 14 | { | |
@@ -24,34 +24,13 @@ attribute_fallthrough(int i) | @@ -24,34 +24,13 @@ attribute_fallthrough(int i) | |||
24 | println("odd"); | 24 | println("odd"); | |
25 | __attribute__((__fallthrough__)); | 25 | __attribute__((__fallthrough__)); | |
26 | case 2: | 26 | case 2: | |
27 | /* | 27 | /* | |
28 | * Only the null statement can have the attribute | 28 | * Only the null statement can have the attribute | |
29 | * 'fallthrough'. This is already caught by GCC, so | 29 | * 'fallthrough'. This is already caught by GCC, so | |
30 | * lint does not need to care. | 30 | * lint does not need to care. | |
31 | */ | 31 | */ | |
32 | /* expect+2: error: syntax error '__attribute__' [249] */ | 32 | /* expect+2: error: syntax error '__attribute__' [249] */ | |
33 | println("prime") | 33 | println("prime") | |
34 | __attribute__((__fallthrough__)); | 34 | __attribute__((__fallthrough__)); | |
35 | } | 35 | } | |
36 | } | 36 | } | |
37 | ||||
38 | /* | |||
39 | * Despite being undocumented, GCC 10 accepts __attribute__((__unused__)) | |||
40 | * at the beginning of a statement. | |||
41 | */ | |||
42 | void | |||
43 | unused_statements(int x) | |||
44 | { | |||
45 | switch (x) { | |||
46 | case 3: | |||
47 | __attribute__((__unused__)) | |||
48 | /* expect+1: error: syntax error 'break' [249] */ | |||
49 | break; | |||
50 | case 4: | |||
51 | goto label; | |||
52 | label: | |||
53 | __attribute__((__unused__)) | |||
54 | /* expect+1: error: syntax error 'return' [249] */ | |||
55 | return; | |||
56 | } | |||
57 | } |
--- src/tests/usr.bin/xlint/lint1/Attic/gcc_attribute_stmt.exp 2022/04/28 07:10:39 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/gcc_attribute_stmt.exp 2022/04/28 21:38:38 1.3
gcc_attribute_label.c(48): error: syntax error 'return' [249]
--- src/usr.bin/xlint/lint1/cgram.y 2022/04/24 20:08:22 1.402
+++ src/usr.bin/xlint/lint1/cgram.y 2022/04/28 21:38:38 1.403
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: cgram.y,v 1.402 2022/04/24 20:08:22 rillig Exp $ */ | 2 | /* $NetBSD: cgram.y,v 1.403 2022/04/28 21:38:38 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) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | __RCSID("$NetBSD: cgram.y,v 1.402 2022/04/24 20:08:22 rillig Exp $"); | 38 | __RCSID("$NetBSD: cgram.y,v 1.403 2022/04/28 21:38:38 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 | |||
47 | extern char *yytext; | 47 | extern 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. | |
@@ -116,27 +116,27 @@ anonymize(sym_t *s) | @@ -116,27 +116,27 @@ anonymize(sym_t *s) | |||
116 | for ( ; s != NULL; s = s->s_next) | 116 | for ( ; s != NULL; s = s->s_next) | |
117 | s->u.s_member.sm_sou_type = NULL; | 117 | s->u.s_member.sm_sou_type = NULL; | |
118 | } | 118 | } | |
119 | 119 | |||
120 | #if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) | 120 | #if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) | |
121 | #define YYSTYPE_TOSTRING cgram_to_string | 121 | #define YYSTYPE_TOSTRING cgram_to_string | |
122 | #endif | 122 | #endif | |
123 | #if defined(YYDEBUG) && defined(YYBISON) | 123 | #if defined(YYDEBUG) && defined(YYBISON) | |
124 | #define YYPRINT cgram_print | 124 | #define YYPRINT cgram_print | |
125 | #endif | 125 | #endif | |
126 | 126 | |||
127 | %} | 127 | %} | |
128 | 128 | |||
129 | %expect 128 | 129 | %expect 132 | |
130 | 130 | |||
131 | %union { | 131 | %union { | |
132 | val_t *y_val; | 132 | val_t *y_val; | |
133 | sbuf_t *y_name; | 133 | sbuf_t *y_name; | |
134 | sym_t *y_sym; | 134 | sym_t *y_sym; | |
135 | op_t y_op; | 135 | op_t y_op; | |
136 | scl_t y_scl; | 136 | scl_t y_scl; | |
137 | tspec_t y_tspec; | 137 | tspec_t y_tspec; | |
138 | tqual_t y_tqual; | 138 | tqual_t y_tqual; | |
139 | type_t *y_type; | 139 | type_t *y_type; | |
140 | tnode_t *y_tnode; | 140 | tnode_t *y_tnode; | |
141 | range_t y_range; | 141 | range_t y_range; | |
142 | strg_t *y_string; | 142 | strg_t *y_string; | |
@@ -1645,27 +1645,27 @@ statement: /* C99 6.8 */ | @@ -1645,27 +1645,27 @@ statement: /* C99 6.8 */ | |||
1645 | non_expr_statement: /* helper for C99 6.8 */ | 1645 | non_expr_statement: /* helper for C99 6.8 */ | |
1646 | type_attribute T_SEMI | 1646 | type_attribute T_SEMI | |
1647 | | labeled_statement | 1647 | | labeled_statement | |
1648 | | compound_statement | 1648 | | compound_statement | |
1649 | | selection_statement | 1649 | | selection_statement | |
1650 | | iteration_statement | 1650 | | iteration_statement | |
1651 | | jump_statement { | 1651 | | jump_statement { | |
1652 | seen_fallthrough = false; | 1652 | seen_fallthrough = false; | |
1653 | } | 1653 | } | |
1654 | | asm_statement | 1654 | | asm_statement | |
1655 | ; | 1655 | ; | |
1656 | 1656 | |||
1657 | labeled_statement: /* C99 6.8.1 */ | 1657 | labeled_statement: /* C99 6.8.1 */ | |
1658 | label statement | 1658 | label type_attribute_opt statement | |
1659 | ; | 1659 | ; | |
1660 | 1660 | |||
1661 | label: | 1661 | label: | |
1662 | T_NAME T_COLON { | 1662 | T_NAME T_COLON { | |
1663 | symtyp = FLABEL; | 1663 | symtyp = FLABEL; | |
1664 | named_label(getsym($1)); | 1664 | named_label(getsym($1)); | |
1665 | } | 1665 | } | |
1666 | | T_CASE constant_expr T_COLON { | 1666 | | T_CASE constant_expr T_COLON { | |
1667 | case_label($2); | 1667 | case_label($2); | |
1668 | seen_fallthrough = true; | 1668 | seen_fallthrough = true; | |
1669 | } | 1669 | } | |
1670 | | T_CASE constant_expr T_ELLIPSIS constant_expr T_COLON { | 1670 | | T_CASE constant_expr T_ELLIPSIS constant_expr T_COLON { | |
1671 | /* XXX: We don't fill all cases */ | 1671 | /* XXX: We don't fill all cases */ |