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: reorder grammar rules



details:   https://anonhg.NetBSD.org/src/rev/878e2ad57e9e
branches:  trunk
changeset: 1022581:878e2ad57e9e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 25 19:05:27 2021 +0000

description:
lint: reorder grammar rules

First the base cases, then the extensions, like in most other rules in
this file.

No functional change.

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute_type.c   |   4 +++-
 tests/usr.bin/xlint/lint1/gcc_attribute_type.exp |   2 +-
 usr.bin/xlint/lint1/cgram.y                      |  13 +++++++------
 3 files changed, 11 insertions(+), 8 deletions(-)

diffs (79 lines):

diff -r 6f6a7c9e4415 -r 878e2ad57e9e tests/usr.bin/xlint/lint1/gcc_attribute_type.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_type.c    Sun Jul 25 18:48:47 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_type.c    Sun Jul 25 19:05:27 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_attribute_type.c,v 1.1 2021/07/06 17:33:07 rillig Exp $    */
+/*     $NetBSD: gcc_attribute_type.c,v 1.2 2021/07/25 19:05:27 rillig Exp $    */
 # 3 "gcc_attribute_type.c"
 
 /*
@@ -7,6 +7,8 @@
  * https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
  */
 
+struct __attribute__((__packed__)) __attribute__(()) packed_record;
+
 struct __attribute__((__packed__)) packed_record {
        unsigned char len[2];
        unsigned long magic;
diff -r 6f6a7c9e4415 -r 878e2ad57e9e tests/usr.bin/xlint/lint1/gcc_attribute_type.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_type.exp  Sun Jul 25 18:48:47 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_type.exp  Sun Jul 25 19:05:27 2021 +0000
@@ -1,1 +1,1 @@
-gcc_attribute_type.c(29): error: syntax error 'syntax_error' [249]
+gcc_attribute_type.c(31): error: syntax error 'syntax_error' [249]
diff -r 6f6a7c9e4415 -r 878e2ad57e9e usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jul 25 18:48:47 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jul 25 19:05:27 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.342 2021/07/25 18:48:47 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.343 2021/07/25 19:05:27 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.342 2021/07/25 18:48:47 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.343 2021/07/25 19:05:27 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -650,7 +650,8 @@
 /* 'conditional_expression' also implements 'logical_OR_expression'. */
 /* K&R ???, C90 ???, C99 6.5.5 to 6.5.15, C11 6.5.5 to 6.5.15 */
 conditional_expression:
-         conditional_expression T_ASTERISK conditional_expression {
+         cast_expression
+       | conditional_expression T_ASTERISK conditional_expression {
                $$ = build_binary($1, MULT, $3);
          }
        | conditional_expression T_MULTIPLICATIVE conditional_expression {
@@ -687,7 +688,7 @@
            T_COLON conditional_expression {
                $$ = build_binary($1, QUEST, build_binary($3, COLON, $5));
          }
-       | cast_expression;
+       ;
 
 /* K&R ???, C90 ???, C99 6.5.16, C11 6.5.16 */
 assignment_expression:
@@ -911,14 +912,14 @@
        ;
 
 struct_or_union:               /* C99 6.7.2.1 */
-         struct_or_union type_attribute
-       | T_STRUCT_OR_UNION {
+         T_STRUCT_OR_UNION {
                symtyp = FTAG;
                begin_declaration_level($1 == STRUCT ? MOS : MOU);
                dcs->d_offset = 0;
                dcs->d_sou_align_in_bits = CHAR_SIZE;
                $$ = $1;
          }
+       | struct_or_union type_attribute
        ;
 
 braced_struct_declaration_list:        /* see C99 6.7.2.1 */



Home | Main Index | Thread Index | Old Index