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: extract clrtyp from noclass_declspecs



details:   https://anonhg.NetBSD.org/src/rev/3f443d0e6a82
branches:  trunk
changeset: 984509:3f443d0e6a82
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 10 17:17:05 2021 +0000

description:
lint: extract clrtyp from noclass_declspecs

Finally each clrtyp pairs up with its corresponding deftyp, which makes
the grammar much easier to understand.  The many grammar rules that
contain these actions now all look the same.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diffs (78 lines):

diff -r 98881dc69423 -r 3f443d0e6a82 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 17:08:37 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 17:17:05 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.294 2021/07/10 17:06:56 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.295 2021/07/10 17:17:05 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.294 2021/07/10 17:06:56 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.295 2021/07/10 17:17:05 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -672,18 +672,18 @@
                symtyp = FVFT;
                $$ = $5;
          }
-       | noclass_declspecs deftyp {
+       | clrtyp noclass_declspecs deftyp {
                symtyp = FMEMBER;
          } type_member_decls type_attribute_opt {
                symtyp = FVFT;
-               $$ = $4;
+               $$ = $5;
          }
        | clrtyp add_type_qualifier_list deftyp type_attribute_opt {
                /* syntax error '%s' */
                error(249, "member without type");
                $$ = NULL;
          }
-       | noclass_declspecs deftyp type_attribute_opt {
+       | clrtyp noclass_declspecs deftyp type_attribute_opt {
                symtyp = FVFT;
                if (!Sflag)
                        /* anonymous struct/union members is a C9X feature */
@@ -709,14 +709,13 @@
        | type_attribute noclass_declspecs_postfix
        ;
 
-/* TODO: pair up clrtyp with deftyp */
 noclass_declspecs_postfix:
-         clrtyp typespec {
+         typespec {
+               add_type($1);
+         }
+       | add_type_qualifier_list typespec {
                add_type($2);
          }
-       | clrtyp add_type_qualifier_list typespec {
-               add_type($3);
-         }
        | noclass_declspecs_postfix T_QUAL {
                add_qualifier($2);
          }
@@ -1272,14 +1271,14 @@
          clrtyp add_type_qualifier_list deftyp {
                $$ = declare_1_abstract(abstract_name());
          }
-       | noclass_declspecs deftyp {
+       | clrtyp noclass_declspecs deftyp {
                $$ = declare_1_abstract(abstract_name());
          }
        | clrtyp add_type_qualifier_list deftyp abstract_declarator {
                $$ = declare_1_abstract($4);
          }
-       | noclass_declspecs deftyp abstract_declarator {
-               $$ = declare_1_abstract($3);
+       | clrtyp noclass_declspecs deftyp abstract_declarator {
+               $$ = declare_1_abstract($4);
          }
        ;
 



Home | Main Index | Thread Index | Old Index