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: move the grammar rule array_size o...



details:   https://anonhg.NetBSD.org/src/rev/bd39f8732675
branches:  trunk
changeset: 984402:bd39f8732675
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 06 05:22:34 2021 +0000

description:
lint: move the grammar rule array_size out of the type/notype section

An array size is used in several grammar rules for different types of
declarations, therefore it doesn't make sense to place that rule
somewhere in the middle, where it disrupted the flow of notype/type
rules.  The whole point of having the notype/type rules grouped is to be
able to quickly compare them, since they are almost equal.

No functional change.

diffstat:

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

diffs (77 lines):

diff -r 83a09d0f0ee0 -r bd39f8732675 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Tue Jul 06 05:12:44 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Tue Jul 06 05:22:34 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.255 2021/07/06 05:12:44 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.256 2021/07/06 05:22:34 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.255 2021/07/06 05:12:44 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.256 2021/07/06 05:22:34 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1016,6 +1016,11 @@
        ;
 
 
+/*
+ * For an explanation of 'notype' in the following rules, see the Bison
+ * manual, section 7.1 "Semantic Info in Token Kinds".
+ */
+
 notype_init_decls:
          notype_init_decl
        | notype_init_decls T_COMMA type_init_decl
@@ -1026,7 +1031,6 @@
        | type_init_decls T_COMMA type_init_decl
        ;
 
-/* See the Bison manual, section 7.1 "Semantic Info in Token Kinds". */
 notype_init_decl:
          notype_decl asm_or_symbolrename_opt {
                cgram_declare($1, false, $2);
@@ -1131,18 +1135,6 @@
          }
        ;
 
-array_size:
-         type_qualifier_list_opt T_SCLASS constant_expr {
-               /* C11 6.7.6.3p7 */
-               if ($2 != STATIC)
-                       yyerror("Bad attribute");
-               /* static array size is a C11 extension */
-               c11ism(343);
-               $$ = $3;
-         }
-       | constant_expr
-       ;
-
 direct_param_decl:
          identifier type_attribute_list {
                $$ = declarator_name(getsym($1));
@@ -1495,6 +1487,18 @@
        | direct_abstract_declarator type_attribute
        ;
 
+array_size:
+         type_qualifier_list_opt T_SCLASS constant_expr {
+               /* C11 6.7.6.3p7 */
+               if ($2 != STATIC)
+                       yyerror("Bad attribute");
+               /* static array size is a C11 extension */
+               c11ism(343);
+               $$ = $3;
+         }
+       | constant_expr
+       ;
+
 non_expr_statement:
          type_attribute T_SEMI
        | labeled_statement



Home | Main Index | Thread Index | Old Index