Module Name: src Committed By: rillig Date: Sat Jul 10 17:17:06 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: extract clrtyp from noclass_declspecs Finally each clrtyp pairs up with its corresponding deftyp, which makes the grammar much easier to understand. The many grammar rules that contain these actions now all look the same. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.294 -r1.295 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/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.294 src/usr.bin/xlint/lint1/cgram.y:1.295 --- src/usr.bin/xlint/lint1/cgram.y:1.294 Sat Jul 10 17:06:56 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sat Jul 10 17:17:05 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.294 2021/07/10 17:06:56 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.295 2021/07/10 17:17:05 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.294 2021/07/10 17:06:56 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.295 2021/07/10 17:17:05 rillig Exp $"); #endif #include <limits.h> @@ -672,18 +672,18 @@ member_declaration: symtyp = FVFT; $$ = $5; } - | noclass_declspecs deftyp { + | clrtyp noclass_declspecs deftyp { symtyp = FMEMBER; } type_member_decls type_attribute_opt { symtyp = FVFT; - $$ = $4; + $$ = $5; } | clrtyp add_type_qualifier_list deftyp type_attribute_opt { /* syntax error '%s' */ error(249, "member without type"); $$ = NULL; } - | noclass_declspecs deftyp type_attribute_opt { + | clrtyp noclass_declspecs deftyp type_attribute_opt { symtyp = FVFT; if (!Sflag) /* anonymous struct/union members is a C9X feature */ @@ -709,13 +709,12 @@ noclass_declspecs: | type_attribute noclass_declspecs_postfix ; -/* TODO: pair up clrtyp with deftyp */ noclass_declspecs_postfix: - clrtyp typespec { - add_type($2); + typespec { + add_type($1); } - | clrtyp add_type_qualifier_list typespec { - add_type($3); + | add_type_qualifier_list typespec { + add_type($2); } | noclass_declspecs_postfix T_QUAL { add_qualifier($2); @@ -1272,14 +1271,14 @@ abstract_declaration: clrtyp add_type_qualifier_list deftyp { $$ = declare_1_abstract(abstract_name()); } - | noclass_declspecs deftyp { + | clrtyp noclass_declspecs deftyp { $$ = declare_1_abstract(abstract_name()); } | clrtyp add_type_qualifier_list deftyp abstract_declarator { $$ = declare_1_abstract($4); } - | noclass_declspecs deftyp abstract_declarator { - $$ = declare_1_abstract($3); + | clrtyp noclass_declspecs deftyp abstract_declarator { + $$ = declare_1_abstract($4); } ;