Module Name:    src
Committed By:   rillig
Date:           Sat Jan 13 11:24:57 UTC 2024

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

Log Message:
lint: clean up grammar for initializers


To generate a diff of this commit:
cvs rdiff -u -r1.482 -r1.483 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/xlint/lint1/init.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.482 src/usr.bin/xlint/lint1/cgram.y:1.483
--- src/usr.bin/xlint/lint1/cgram.y:1.482	Sat Jan 13 01:23:39 2024
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Jan 13 11:24:57 2024
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.482 2024/01/13 01:23:39 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.483 2024/01/13 11:24:57 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.482 2024/01/13 01:23:39 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.483 2024/01/13 11:24:57 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -295,7 +295,6 @@ is_either(const char *s, const char *a, 
 %type	<y_generic>	generic_assoc_list
 %type	<y_generic>	generic_association
 %type	<y_tnode>	postfix_expression
-/* No type for comma_opt. */
 %type	<y_tnode>	gcc_statement_expr_list
 %type	<y_tnode>	gcc_statement_expr_item
 %type	<y_op>		point_or_arrow
@@ -373,7 +372,6 @@ is_either(const char *s, const char *a, 
 /* No type for braced_initializer. */
 /* No type for initializer. */
 /* No type for initializer_list. */
-/* No type for initializer_list_item. */
 /* No type for designation. */
 /* No type for designator_list. */
 /* No type for designator. */
@@ -591,11 +589,6 @@ postfix_expression:
 	}
 ;
 
-comma_opt:			/* helper for 'postfix_expression' */
-	/* empty */
-|	T_COMMA
-;
-
 /*
  * The inner part of a GCC statement-expression of the form ({ ... }).
  *
@@ -1636,7 +1629,8 @@ braced_initializer:
 		c23ism(353);
 	}
 	/* K&R ---, C90 ---, C99 6.7.8, C11 6.7.9, C23 6.7.10 */
-|	init_lbrace initializer_list comma_opt init_rbrace
+|	init_lbrace initializer_list init_rbrace
+|	init_lbrace initializer_list T_COMMA init_rbrace
 ;
 
 initializer:			/* C99 6.7.8 "Initialization" */
@@ -1646,23 +1640,21 @@ initializer:			/* C99 6.7.8 "Initializat
 |	init_lbrace init_rbrace {
 		/* XXX: Empty braces are not covered by C99 6.7.8. */
 	}
-|	init_lbrace initializer_list comma_opt init_rbrace
+|	init_lbrace initializer_list init_rbrace
+|	init_lbrace initializer_list T_COMMA init_rbrace
 	/* XXX: What is this error handling for? */
 |	error
 ;
 
 initializer_list:		/* C99 6.7.8 "Initialization" */
-	initializer_list_item
-|	initializer_list T_COMMA initializer_list_item
-;
-
-initializer_list_item:		/* helper */
-	designation initializer
-|	initializer
+	initializer
+|	designation initializer
+|	initializer_list T_COMMA initializer
+|	initializer_list T_COMMA designation initializer
 ;
 
 designation:			/* C99 6.7.8 "Initialization" */
-	/* empty */ {
+	{
 		begin_designation();
 	} designator_list T_ASSIGN
 |	identifier T_COLON {

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.255 src/usr.bin/xlint/lint1/init.c:1.256
--- src/usr.bin/xlint/lint1/init.c:1.255	Thu Jan 11 23:26:39 2024
+++ src/usr.bin/xlint/lint1/init.c	Sat Jan 13 11:24:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.255 2024/01/11 23:26:39 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.256 2024/01/13 11:24:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: init.c,v 1.255 2024/01/11 23:26:39 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.256 2024/01/13 11:24:57 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -992,10 +992,9 @@ begin_designation(void)
 	if (in->in_err)
 		return;
 
-	brace_level *bl = in->in_brace_level;
-	lint_assert(bl != NULL);
-	bl->bl_designation.dn_len = 0;
-	designation_debug(&bl->bl_designation);
+	designation *dn = &in->in_brace_level->bl_designation;
+	dn->dn_len = 0;
+	designation_debug(dn);
 }
 
 void

Reply via email to