Sat Jul 10 21:44:51 2021 UTC ()
lint: inline grammar rules declmod and qualifier_or_storage_class

The rule declmod had a confusing name since declmods was not exactly a
list of declmod.

Inlining the rules reduces the abstraction level.  There are still some
shift/reduce conflicts in that area, so make the rules as simple as
possible, in order to resolve these conflicts.

No functional change.


(rillig)
diff -r1.303 -r1.304 src/usr.bin/xlint/lint1/cgram.y

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

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/10 21:08:16 1.303
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/10 21:44:51 1.304
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.303 2021/07/10 21:08:16 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.304 2021/07/10 21:44:51 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.303 2021/07/10 21:08:16 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.304 2021/07/10 21:44:51 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.
@@ -525,43 +525,42 @@ begin_type: @@ -525,43 +525,42 @@ begin_type:
525 } 525 }
526 ; 526 ;
527 527
528end_type: 528end_type:
529 /* empty */ { 529 /* empty */ {
530 end_type(); 530 end_type();
531 } 531 }
532 ; 532 ;
533 533
534declaration_specifiers: /* C99 6.7 */ 534declaration_specifiers: /* C99 6.7 */
535 add_type_specifier 535 add_type_specifier
536 | declmods add_type_specifier 536 | declmods add_type_specifier
537 | type_attribute declaration_specifiers 537 | type_attribute declaration_specifiers
538 | declaration_specifiers declmod 538 | declaration_specifiers add_storage_class
539 | declaration_specifiers add_notype_type_specifier 539 | declaration_specifiers add_notype_type_specifier
 540 | declaration_specifiers add_type_qualifier
 541 | declaration_specifiers type_attribute
540 ; 542 ;
541 543
542declmods: 544declmods:
543 qualifier_or_storage_class 545 add_storage_class
544 | declmods declmod 546 | add_type_qualifier
 547 | declmods add_storage_class
 548 | declmods add_type_qualifier
 549 | declmods type_attribute
545 ; 550 ;
546 551
547declmod: 552add_storage_class:
548 qualifier_or_storage_class 553 T_SCLASS {
549 | type_attribute 
550 ; 
551 
552qualifier_or_storage_class: 
553 add_type_qualifier 
554 | T_SCLASS { 
555 add_storage_class($1); 554 add_storage_class($1);
556 } 555 }
557 ; 556 ;
558 557
559add_type_specifier: 558add_type_specifier:
560 type_specifier { 559 type_specifier {
561 add_type($1); 560 add_type($1);
562 } 561 }
563 ; 562 ;
564 563
565type_attribute_list_opt: 564type_attribute_list_opt:
566 /* empty */ 565 /* empty */
567 | type_attribute_list 566 | type_attribute_list