Module Name: src
Committed By: rillig
Date: Thu Jul 8 04:09:10 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: add grammar rule type_attribute_list_opt
Since type attributes (and GCC attributes as well) often modify the
preceding identifier, without referring to $$, the easiest way to
integrate them into the grammar is to define a separate grammar rule
that can be placed wherever these attributes are allowed. This avoids
duplicate actions like in direct_param_decl.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 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.270 src/usr.bin/xlint/lint1/cgram.y:1.271
--- src/usr.bin/xlint/lint1/cgram.y:1.270 Thu Jul 8 03:55:54 2021
+++ src/usr.bin/xlint/lint1/cgram.y Thu Jul 8 04:09:10 2021
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.270 2021/07/08 03:55:54 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.271 2021/07/08 04:09:10 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.270 2021/07/08 03:55:54 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.271 2021/07/08 04:09:10 rillig Exp $");
#endif
#include <limits.h>
@@ -343,7 +343,6 @@ anonymize(sym_t *s)
%type <y_generic> generic_assoc_list
%type <y_generic> generic_association
-
%%
program:
@@ -645,14 +644,13 @@ struct_spec:
;
struct:
- struct 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;
- }
+ } type_attribute_list_opt
;
struct_tag:
@@ -1035,10 +1033,7 @@ notype_param_decl:
;
direct_param_decl:
- identifier type_attribute_list {
- $$ = declarator_name(getsym($1));
- }
- | identifier {
+ identifier type_attribute_list_opt {
$$ = declarator_name(getsym($1));
}
| T_LPAREN notype_param_decl T_RPAREN {
@@ -1058,8 +1053,7 @@ direct_param_decl:
;
direct_notype_param_decl:
- /* XXX: missing identifier type_attribute_list? */
- identifier {
+ identifier /* XXX: missing type_attribute_list_opt? */ {
$$ = declarator_name(getsym($1));
}
| T_LPAREN notype_param_decl T_RPAREN {
@@ -1982,6 +1976,11 @@ comma_opt:
/* GCC extensions */
+type_attribute_list_opt:
+ /* empty */
+ | type_attribute_list
+ ;
+
type_attribute_list:
type_attribute
| type_attribute_list type_attribute