Sat Jul 10 04:47:25 2021 UTC ()
lint: merge duplicate code in declmods and declmod

No functional change.


(rillig)
diff -r1.278 -r1.279 src/usr.bin/xlint/lint1/cgram.y

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

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/10 04:25:47 1.278
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/10 04:47:25 1.279
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.278 2021/07/10 04:25:47 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.279 2021/07/10 04:47:25 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.278 2021/07/10 04:25:47 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.279 2021/07/10 04:47:25 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.
@@ -539,43 +539,42 @@ declaration_specifiers: /* C99 6.7 */ @@ -539,43 +539,42 @@ declaration_specifiers: /* C99 6.7 */
539 add_type($1); 539 add_type($1);
540 } 540 }
541 | declmods typespec { 541 | declmods typespec {
542 add_type($2); 542 add_type($2);
543 } 543 }
544 | type_attribute declaration_specifiers 544 | type_attribute declaration_specifiers
545 | declaration_specifiers declmod 545 | declaration_specifiers declmod
546 | declaration_specifiers notype_typespec { 546 | declaration_specifiers notype_typespec {
547 add_type($2); 547 add_type($2);
548 } 548 }
549 ; 549 ;
550 550
551declmods: 551declmods:
552 clrtyp T_QUAL { 552 clrtyp qualifier_or_storage_class
553 add_qualifier($2); 
554 } 
555 | clrtyp T_SCLASS { 
556 add_storage_class($2); 
557 } 
558 | declmods declmod 553 | declmods declmod
559 ; 554 ;
560 555
561declmod: 556declmod:
 557 qualifier_or_storage_class
 558 | type_attribute
 559 ;
 560
 561qualifier_or_storage_class:
562 T_QUAL { 562 T_QUAL {
563 add_qualifier($1); 563 add_qualifier($1);
564 } 564 }
565 | T_SCLASS { 565 | T_SCLASS {
566 add_storage_class($1); 566 add_storage_class($1);
567 } 567 }
568 | type_attribute 
569 ; 568 ;
570 569
571clrtyp_typespec: 570clrtyp_typespec:
572 clrtyp notype_typespec { 571 clrtyp notype_typespec {
573 $$ = $2; 572 $$ = $2;
574 } 573 }
575 | T_TYPENAME clrtyp { 574 | T_TYPENAME clrtyp {
576 $$ = getsym($1)->s_type; 575 $$ = getsym($1)->s_type;
577 } 576 }
578 ; 577 ;
579 578
580typespec: 579typespec:
581 notype_typespec 580 notype_typespec