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: reduce shift/reduce conflicts in C...



details:   https://anonhg.NetBSD.org/src/rev/957c2815023f
branches:  trunk
changeset: 365775:957c2815023f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Apr 24 13:38:57 2022 +0000

description:
lint: reduce shift/reduce conflicts in C grammar

Previously, direct_abstract_declarator allowed type attributes like
_Noreturn to be prepended and appended to a type without specifying any
order.

No functional change intended.

diffstat:

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

diffs (51 lines):

diff -r c3e795495460 -r 957c2815023f usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Apr 24 11:51:09 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Apr 24 13:38:57 2022 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.395 2022/04/16 09:22:25 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.396 2022/04/24 13:38:57 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.395 2022/04/16 09:22:25 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.396 2022/04/24 13:38:57 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -126,7 +126,7 @@
 
 %}
 
-%expect 150
+%expect 144
 
 %union {
        val_t   *y_val;
@@ -1416,6 +1416,12 @@
        | pointer direct_abstract_declarator {
                $$ = add_pointer($2, $1);
          }
+       | type_attribute_list direct_abstract_declarator {
+               $$ = $2;
+         }
+       | pointer type_attribute_list direct_abstract_declarator {
+               $$ = add_pointer($3, $1);
+         }
        ;
 
 /* K&R ---, C90 ???, C99 6.7.6, C11 6.7.7 */
@@ -1427,9 +1433,6 @@
        | T_LBRACK array_size_opt T_RBRACK {
                $$ = add_array(abstract_name(), $2.has_dim, $2.dim);
          }
-       | type_attribute direct_abstract_declarator {
-               $$ = $2;
-         }
        | direct_abstract_declarator T_LBRACK array_size_opt T_RBRACK {
                $$ = add_array($1, $3.has_dim, $3.dim);
          }



Home | Main Index | Thread Index | Old Index