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: remove noclass_declmods from grammar



details:   https://anonhg.NetBSD.org/src/rev/ce89ee88d9ed
branches:  trunk
changeset: 1022233:ce89ee88d9ed
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 10 10:56:30 2021 +0000

description:
lint: remove noclass_declmods from grammar

That rule was hard to understand since it contained clrtyp but not the
corresponding deftyp.  It's easier to read when a grammar rule contains
both clrtyp and deftyp in the same line.

C99 does not mention the term 'decl-modifier' anywhere, and in fact the
only thing that this grammar rule allowed was a type-qualifier-list.
The new name better reflect this.

No functional change.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_anon_struct.c |   8 +++---
 usr.bin/xlint/lint1/cgram.y                   |  34 ++++++++++++++------------
 2 files changed, 22 insertions(+), 20 deletions(-)

diffs (121 lines):

diff -r b3205978b87a -r ce89ee88d9ed tests/usr.bin/xlint/lint1/d_c99_anon_struct.c
--- a/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c     Sat Jul 10 10:30:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c     Sat Jul 10 10:56:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_anon_struct.c,v 1.3 2021/01/31 14:39:31 rillig Exp $     */
+/*     $NetBSD: d_c99_anon_struct.c,v 1.4 2021/07/10 10:56:31 rillig Exp $     */
 # 3 "d_c99_anon_struct.c"
 
 /* Anonymous struct test */
@@ -10,7 +10,7 @@
        int y;
 };
 
-struct bar {
+struct rect {
        struct {
                struct point top_left;
                struct point bottom_right;
@@ -22,7 +22,7 @@
 int
 main(void)
 {
-       struct bar b;
-       b.top_left.x = 1;
+       struct rect r;
+       r.top_left.x = 1;
        return 0;
 }
diff -r b3205978b87a -r ce89ee88d9ed usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 10:30:26 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Jul 10 10:56:30 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.286 2021/07/10 10:30:26 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.287 2021/07/10 10:56:30 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.286 2021/07/10 10:30:26 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.287 2021/07/10 10:56:30 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -675,12 +675,12 @@
        ;
 
 member_declaration:
-         noclass_declmods deftyp {
+         clrtyp add_type_qualifier_list deftyp {
                /* too late, i know, but getsym() compensates it */
                symtyp = FMEMBER;
          } notype_member_decls type_attribute_opt {
                symtyp = FVFT;
-               $$ = $4;
+               $$ = $5;
          }
        | noclass_declspecs deftyp {
                symtyp = FMEMBER;
@@ -688,7 +688,7 @@
                symtyp = FVFT;
                $$ = $4;
          }
-       | noclass_declmods deftyp type_attribute_opt {
+       | clrtyp add_type_qualifier_list deftyp type_attribute_opt {
                symtyp = FVFT;
                if (!Sflag)
                        /* anonymous struct/union members is a C9X feature */
@@ -733,8 +733,8 @@
          clrtyp_typespec {
                add_type($1);
          }
-       | noclass_declmods typespec {
-               add_type($2);
+       | clrtyp add_type_qualifier_list typespec {
+               add_type($3);
          }
        | noclass_declspecs_postfix T_QUAL {
                add_qualifier($2);
@@ -745,12 +745,14 @@
        | noclass_declspecs_postfix type_attribute
        ;
 
-noclass_declmods:
-         clrtyp T_QUAL {
-               add_qualifier($2);
-         }
-       | noclass_declmods T_QUAL {
-               add_qualifier($2);
+add_type_qualifier_list:
+         add_type_qualifier
+       | add_type_qualifier_list add_type_qualifier
+       ;
+
+add_type_qualifier:
+         T_QUAL {
+               add_qualifier($1);
          }
        ;
 
@@ -1286,14 +1288,14 @@
        ;
 
 abstract_declaration:
-         noclass_declmods deftyp {
+         clrtyp add_type_qualifier_list deftyp {
                $$ = declare_1_abstract(abstract_name());
          }
        | noclass_declspecs deftyp {
                $$ = declare_1_abstract(abstract_name());
          }
-       | noclass_declmods deftyp abstract_declarator {
-               $$ = declare_1_abstract($3);
+       | clrtyp add_type_qualifier_list deftyp abstract_declarator {
+               $$ = declare_1_abstract($4);
          }
        | noclass_declspecs deftyp abstract_declarator {
                $$ = declare_1_abstract($3);



Home | Main Index | Thread Index | Old Index