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: add grammar rule type_attribute_li...
details: https://anonhg.NetBSD.org/src/rev/7881b783de51
branches: trunk
changeset: 984445:7881b783de51
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 08 04:09:10 2021 +0000
description:
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.
diffstat:
usr.bin/xlint/lint1/cgram.y | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diffs (78 lines):
diff -r ba47b37fa535 -r 7881b783de51 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Thu Jul 08 03:55:54 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Thu Jul 08 04:09:10 2021 +0000
@@ -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 @@
%type <y_generic> generic_assoc_list
%type <y_generic> generic_association
-
%%
program:
@@ -645,14 +644,13 @@
;
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 @@
;
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_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 @@
/* GCC extensions */
+type_attribute_list_opt:
+ /* empty */
+ | type_attribute_list
+ ;
+
type_attribute_list:
type_attribute
| type_attribute_list type_attribute
Home |
Main Index |
Thread Index |
Old Index