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 single semicolon to external_...



details:   https://anonhg.NetBSD.org/src/rev/7928cb22eaf8
branches:  trunk
changeset: 1022511:7928cb22eaf8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 23 15:14:49 2021 +0000

description:
lint: move single semicolon to external_declaration

This aligns more closely with the grammar from GCC's parser.  The global
cleanup from the grammar rule 'external_declaration:
top_level_declaration' is not performed anymore, which doesn't matter
since there is nothing to clean up after a single semicolon.

No functional change.

diffstat:

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

diffs (64 lines):

diff -r 56027c78d857 -r 7928cb22eaf8 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Jul 23 14:38:58 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Jul 23 15:14:49 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.335 2021/07/23 15:14:49 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.334 2021/07/21 21:24:45 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.335 2021/07/23 15:14:49 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1870,8 +1870,7 @@
        ;
 
 external_declaration:          /* C99 6.9 */
-         asm_statement
-       | function_definition {
+         function_definition {
                global_clean_up_decl(false);
                clear_warning_flags();
          }
@@ -1879,6 +1878,16 @@
                global_clean_up_decl(false);
                clear_warning_flags();
          }
+       | asm_statement         /* GCC extension */
+       | T_SEMI {              /* GCC extension */
+               if (sflag) {
+                       /* empty declaration */
+                       error(0);
+               } else if (!tflag) {
+                       /* empty declaration */
+                       warning(0);
+               }
+         }
        ;
 
 /*
@@ -1891,16 +1900,7 @@
  * See 'declaration' for all other declarations.
  */
 top_level_declaration:         /* C99 6.9 calls this 'declaration' */
-         T_SEMI {
-               if (sflag) {
-                       /* empty declaration */
-                       error(0);
-               } else if (!tflag) {
-                       /* empty declaration */
-                       warning(0);
-               }
-         }
-       | begin_type end_type notype_init_declarators T_SEMI {
+         begin_type end_type notype_init_declarators T_SEMI {
                if (sflag) {
                        /* old style declaration; add 'int' */
                        error(1);



Home | Main Index | Thread Index | Old Index