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: rename grammar rule 'declaration' ...



details:   https://anonhg.NetBSD.org/src/rev/627d92c2ae92
branches:  trunk
changeset: 1022391:627d92c2ae92
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 15 18:13:25 2021 +0000

description:
lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  16 ++++++++++------
 usr.bin/xlint/lint1/lint1.h |   6 +++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diffs (89 lines):

diff -r fe8f9ac94e78 -r 627d92c2ae92 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Thu Jul 15 17:48:10 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Thu Jul 15 18:13:25 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.325 2021/07/15 17:20:57 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.326 2021/07/15 18:13:25 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.325 2021/07/15 17:20:57 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.326 2021/07/15 18:13:25 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -181,7 +181,7 @@
 
 /*
  * predefined type keywords (char, int, short, long, unsigned, signed,
- * float, double, void); see T_TYPENAME
+ * float, double, void); see T_TYPENAME for types from typedef
  */
 %token <y_tspec>       T_TYPE
 
@@ -527,7 +527,7 @@
        ;
 
 gcc_statement_expr_item:
-         declaration {
+         declaration_or_error {
                clear_warning_flags();
                $$ = NULL;
          }
@@ -720,6 +720,11 @@
          conditional_expression
        ;
 
+declaration_or_error:
+         declaration
+       | error T_SEMI
+       ;
+
 declaration:                   /* C99 6.7 */
          begin_type_declmods end_type T_SEMI {
                if (dcs->d_scl == TYPEDEF) {
@@ -742,7 +747,6 @@
          }
        | begin_type_declaration_specifiers end_type
            type_init_declarators T_SEMI
-       | error T_SEMI
        ;
 
 begin_type_declaration_specifiers:     /* see C99 6.7 */
@@ -1672,7 +1676,7 @@
        ;
 
 block_item:                    /* C99 6.8.2 */
-         declaration {
+         declaration_or_error {
                $$ = false;
                restore_warning_flags();
          }
diff -r fe8f9ac94e78 -r 627d92c2ae92 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Thu Jul 15 17:48:10 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Thu Jul 15 18:13:25 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.114 2021/07/10 17:35:54 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.115 2021/07/15 18:13:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -209,11 +209,11 @@
 } symt_t;
 
 /*
- * storage classes
+ * storage classes and related things
  */
 typedef enum {
        NOSCL,
-       EXTERN,         /* external symbols (indep. of decl_t) */
+       EXTERN,         /* external symbols (independent of decl_t) */
        STATIC,         /* static symbols (local and global) */
        AUTO,           /* automatic symbols (except register) */
        REG,            /* register */



Home | Main Index | Thread Index | Old Index