Sat Jul 10 05:42:30 2021 UTC ()
lint: do not allow __packed or _Alignas in statement

When the rule 'statement: type_attribute T_SEMI' was added in cgram.y
1.214 from 2021-04-14, type_attribute was the closest match since there
was no definition for gcc_attribute yet.


(rillig)
diff -r1.281 -r1.282 src/usr.bin/xlint/lint1/cgram.y

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

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/10 05:03:03 1.281
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/10 05:42:29 1.282
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.281 2021/07/10 05:03:03 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.282 2021/07/10 05:42:29 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.281 2021/07/10 05:03:03 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.282 2021/07/10 05:42:29 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.
@@ -1355,27 +1355,27 @@ direct_abstract_declarator_postfix: /* C @@ -1355,27 +1355,27 @@ direct_abstract_declarator_postfix: /* C
1355array_size: 1355array_size:
1356 type_qualifier_list_opt T_SCLASS constant_expr { 1356 type_qualifier_list_opt T_SCLASS constant_expr {
1357 /* C11 6.7.6.3p7 */ 1357 /* C11 6.7.6.3p7 */
1358 if ($2 != STATIC) 1358 if ($2 != STATIC)
1359 yyerror("Bad attribute"); 1359 yyerror("Bad attribute");
1360 /* static array size is a C11 extension */ 1360 /* static array size is a C11 extension */
1361 c11ism(343); 1361 c11ism(343);
1362 $$ = $3; 1362 $$ = $3;
1363 } 1363 }
1364 | constant_expr 1364 | constant_expr
1365 ; 1365 ;
1366 1366
1367non_expr_statement: 1367non_expr_statement:
1368 type_attribute T_SEMI 1368 gcc_attribute T_SEMI
1369 | labeled_statement 1369 | labeled_statement
1370 | compound_statement 1370 | compound_statement
1371 | selection_statement 1371 | selection_statement
1372 | iteration_statement 1372 | iteration_statement
1373 | jump_statement { 1373 | jump_statement {
1374 seen_fallthrough = false; 1374 seen_fallthrough = false;
1375 } 1375 }
1376 | asm_statement 1376 | asm_statement
1377 ; 1377 ;
1378 1378
1379statement: /* C99 6.8 */ 1379statement: /* C99 6.8 */
1380 expression_statement 1380 expression_statement
1381 | non_expr_statement 1381 | non_expr_statement