Module Name:    src
Committed By:   rillig
Date:           Sat Sep 28 11:20:29 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: gcc_attribute_var.c
        src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: reduce shift/reduce conflicts in grammar

In an anonymous member declaration, the type attributes are already
parsed by the type specifier.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c
cvs rdiff -u -r1.507 -r1.508 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.11 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.12
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.11	Sat Jul 15 21:47:35 2023
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c	Sat Sep 28 11:20:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_var.c,v 1.11 2023/07/15 21:47:35 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_var.c,v 1.12 2024/09/28 11:20:29 rillig Exp $	*/
 # 3 "gcc_attribute_var.c"
 
 /*
@@ -83,3 +83,20 @@ struct attribute_in_member_declaration {
 	    bit2:2 __attribute__(()),
 	    bit3:3 __attribute__(());
 };
+
+
+void
+anonymous_members(void)
+{
+	struct single_attribute_outer {
+		struct single_attribute_inner {
+			int member;
+		} __attribute__(());
+	} __attribute__(());
+
+	struct multiple_attributes_outer {
+		struct multiple_attributes_inner {
+			int member;
+		} __attribute__(()) __attribute__(());
+	} __attribute__(()) __attribute__(());
+}

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.507 src/usr.bin/xlint/lint1/cgram.y:1.508
--- src/usr.bin/xlint/lint1/cgram.y:1.507	Thu Aug 29 20:35:19 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Sep 28 11:20:29 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.507 2024/08/29 20:35:19 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.508 2024/09/28 11:20:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.507 2024/08/29 20:35:19 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.508 2024/09/28 11:20:29 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -154,7 +154,7 @@ new_attribute(const sbuf_t *prefix, cons
 
 %}
 
-%expect 110
+%expect 107
 
 %union {
 	val_t	*y_val;
@@ -1243,8 +1243,7 @@ member_declaration:
 		error(249, "member without type");
 		$$ = NULL;
 	}
-|	begin_type_specifier_qualifier_list end_type type_attribute_opt
-	    T_SEMI {
+|	begin_type_specifier_qualifier_list end_type T_SEMI {
 		set_sym_kind(SK_VCFT);
 		if (!allow_c11 && !allow_gcc)
 			/* anonymous struct/union members is a C11 feature */

Reply via email to