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: fix parsing of enumerators with __...



details:   https://anonhg.NetBSD.org/src/rev/241750890df3
branches:  trunk
changeset: 984851:241750890df3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 25 18:48:47 2021 +0000

description:
lint: fix parsing of enumerators with __attribute__

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute_enum.c   |  10 +++++-----
 tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp |   3 +--
 usr.bin/xlint/lint1/cgram.y                      |  10 +++++-----
 3 files changed, 11 insertions(+), 12 deletions(-)

diffs (70 lines):

diff -r 1166ab8ed8a3 -r 241750890df3 tests/usr.bin/xlint/lint1/gcc_attribute_enum.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c    Sun Jul 25 18:44:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c    Sun Jul 25 18:48:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_attribute_enum.c,v 1.3 2021/07/25 18:44:21 rillig Exp $    */
+/*     $NetBSD: gcc_attribute_enum.c,v 1.4 2021/07/25 18:48:47 rillig Exp $    */
 # 3 "gcc_attribute_enum.c"
 
 /*
@@ -30,15 +30,15 @@
  */
 
 enum without_initializer {
-       /* expect+1: error: syntax error '__attribute__' [249] */
        NO_INIT_FIRST __attribute__(()),
-       NO_INIT__LAST __attribute__(())
+       NO_INIT_LAST __attribute__(())
 };
 
 enum with_initializer {
-       /* expect+1: error: syntax error '__attribute__' [249] */
        INIT_FIRST __attribute__(()) = 1,
-       INIT__LAST __attribute__(()) = 2
+       INIT_LAST __attribute__(()) = 2,
+       /* expect+1: syntax error '__attribute__' [249] */
+       INIT_WRONG = 3 __attribute__(()),
 };
 
 enum tag {
diff -r 1166ab8ed8a3 -r 241750890df3 tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp  Sun Jul 25 18:44:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp  Sun Jul 25 18:48:47 2021 +0000
@@ -1,2 +1,1 @@
-gcc_attribute_enum.c(34): error: syntax error '__attribute__' [249]
-gcc_attribute_enum.c(40): error: syntax error '__attribute__' [249]
+gcc_attribute_enum.c(41): error: syntax error '__attribute__' [249]
diff -r 1166ab8ed8a3 -r 241750890df3 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jul 25 18:44:21 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jul 25 18:48:47 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.341 2021/07/25 18:44:21 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.342 2021/07/25 18:48:47 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.341 2021/07/25 18:44:21 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.342 2021/07/25 18:48:47 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1101,11 +1101,11 @@
        ;
 
 enumerator:                    /* C99 6.7.2.2 */
-         identifier_sym {
+         identifier_sym gcc_attribute_list_opt {
                $$ = enumeration_constant($1, enumval, true);
          }
-       | identifier_sym T_ASSIGN constant_expr {
-               $$ = enumeration_constant($1, to_int_constant($3, true),
+       | identifier_sym gcc_attribute_list_opt T_ASSIGN constant_expr {
+               $$ = enumeration_constant($1, to_int_constant($4, true),
                    false);
          }
        ;



Home | Main Index | Thread Index | Old Index