Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: split grammar rule clrtyp_declmods



details:   https://anonhg.NetBSD.org/src/rev/30fb893f71be
branches:  trunk
changeset: 984506:30fb893f71be
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 10 16:54:40 2021 +0000

description:
lint: split grammar rule clrtyp_declmods

By extracting clrtyp from that rule, clrtyp and deftyp pair up nicely in
most of the grammar rules.  These two actions delimit the common part of
a declaration that declares multiple identifiers.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diffs (121 lines):

diff -r 84f37f65ebe5 -r 30fb893f71be usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 16:41:51 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 16:54:40 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.292 2021/07/10 16:41:51 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.293 2021/07/10 16:54:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.292 2021/07/10 16:41:51 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.293 2021/07/10 16:54:40 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -444,8 +444,8 @@
          clrtyp deftyp notype_decl {
                $$ = $3;
          }
-       | clrtyp_declmods deftyp notype_decl {
-               $$ = $3;
+       | clrtyp declmods deftyp notype_decl {
+               $$ = $4;
          }
        | declaration_specifiers deftyp type_decl {
                $$ = $3;
@@ -469,11 +469,11 @@
  * needs other error handling.
  */
 arg_declaration:
-         clrtyp_declmods deftyp T_SEMI {
+         clrtyp declmods deftyp T_SEMI {
                /* empty declaration */
                warning(2);
          }
-       | clrtyp_declmods deftyp notype_init_decls T_SEMI
+       | clrtyp declmods deftyp notype_init_decls T_SEMI
        | declaration_specifiers deftyp T_SEMI {
                if (!dcs->d_nonempty_decl) {
                        /* empty declaration */
@@ -489,7 +489,7 @@
                        warning(3, type_name(dcs->d_type));
                }
          }
-       | clrtyp_declmods error
+       | clrtyp declmods error
        | declaration_specifiers error
        ;
 
@@ -499,7 +499,7 @@
        ;
 
 declaration_noerror:           /* see C99 6.7 'declaration' */
-         clrtyp_declmods deftyp T_SEMI {
+         clrtyp declmods deftyp T_SEMI {
                if (dcs->d_scl == TYPEDEF) {
                        /* typedef declares no type name */
                        warning(72);
@@ -508,7 +508,7 @@
                        warning(2);
                }
          }
-       | clrtyp_declmods deftyp notype_init_decls T_SEMI
+       | clrtyp declmods deftyp notype_init_decls T_SEMI
        | declaration_specifiers deftyp T_SEMI {
                if (dcs->d_scl == TYPEDEF) {
                        /* typedef declares no type name */
@@ -537,8 +537,8 @@
          clrtyp typespec {
                add_type($2);
          }
-       | clrtyp_declmods typespec {
-               add_type($2);
+       | clrtyp declmods typespec {
+               add_type($3);
          }
        | type_attribute declaration_specifiers
        | declaration_specifiers declmod
@@ -547,9 +547,9 @@
          }
        ;
 
-clrtyp_declmods:
-         clrtyp qualifier_or_storage_class
-       | clrtyp_declmods declmod
+declmods:
+         qualifier_or_storage_class
+       | declmods declmod
        ;
 
 declmod:
@@ -1150,20 +1150,20 @@
 
 /* XXX: C99 6.7.5 defines the same name, but it looks completely different. */
 parameter_declaration:
-         clrtyp_declmods deftyp {
+         clrtyp declmods deftyp {
                $$ = declare_argument(abstract_name(), false);
          }
        | declaration_specifiers deftyp {
                $$ = declare_argument(abstract_name(), false);
          }
-       | clrtyp_declmods deftyp notype_param_decl {
-               $$ = declare_argument($3, false);
+       | clrtyp declmods deftyp notype_param_decl {
+               $$ = declare_argument($4, false);
          }
        | declaration_specifiers deftyp type_param_decl {
                $$ = declare_argument($3, false);
          }
-       | clrtyp_declmods deftyp abstract_declarator {
-               $$ = declare_argument($3, false);
+       | clrtyp declmods deftyp abstract_declarator {
+               $$ = declare_argument($4, false);
          }
        | declaration_specifiers deftyp abstract_declarator {
                $$ = declare_argument($3, false);



Home | Main Index | Thread Index | Old Index