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: merge duplicate code for abstract_...
details: https://anonhg.NetBSD.org/src/rev/ec75192099a7
branches: trunk
changeset: 984856:ec75192099a7
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 25 19:57:22 2021 +0000
description:
lint: merge duplicate code for abstract_declaration
No functional change; same code coverage outside of cgram.y.
diffstat:
usr.bin/xlint/lint1/cgram.y | 36 ++++++++++++++++++++++--------------
1 files changed, 22 insertions(+), 14 deletions(-)
diffs (78 lines):
diff -r c40d0df2b67a -r ec75192099a7 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Jul 25 19:41:33 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Jul 25 19:57:22 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.344 2021/07/25 19:27:26 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 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.344 2021/07/25 19:27:26 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 rillig Exp $");
#endif
#include <limits.h>
@@ -337,7 +337,9 @@
%type <y_sym> identifier_list
%type <y_type> type_name
%type <y_sym> abstract_declaration
+%type <y_sym> abstract_declarator_opt
%type <y_sym> abstract_declarator
+%type <y_sym> direct_abstract_declarator_opt
%type <y_sym> direct_abstract_declarator
%type <y_sym> abstract_decl_param_list
%type <y_sym> vararg_parameter_type_list
@@ -1371,30 +1373,36 @@
;
abstract_declaration: /* specific to lint */
- begin_type_qualifier_list end_type {
- $$ = declare_1_abstract(abstract_name());
+ begin_type_qualifier_list end_type abstract_declarator_opt {
+ $$ = declare_1_abstract($3);
}
- | begin_type_specifier_qualifier_list end_type {
- $$ = declare_1_abstract(abstract_name());
- }
- | begin_type_qualifier_list end_type abstract_declarator {
+ | begin_type_specifier_qualifier_list end_type
+ abstract_declarator_opt {
$$ = declare_1_abstract($3);
}
- | begin_type_specifier_qualifier_list end_type abstract_declarator {
- $$ = declare_1_abstract($3);
+ ;
+
+abstract_declarator_opt:
+ /* empty */ {
+ $$ = abstract_name();
}
+ | abstract_declarator
;
/* K&R 8.7, C90 ???, C99 6.7.6, C11 6.7.7 */
/* In K&R, abstract-declarator could be empty and was still simpler. */
abstract_declarator:
- pointer {
- $$ = add_pointer(abstract_name(), $1);
+ pointer direct_abstract_declarator_opt {
+ $$ = add_pointer($2, $1);
}
| direct_abstract_declarator
- | pointer direct_abstract_declarator {
- $$ = add_pointer($2, $1);
+ ;
+
+direct_abstract_declarator_opt:
+ /* empty */ {
+ $$ = abstract_name();
}
+ | direct_abstract_declarator
;
/* K&R ---, C90 ???, C99 6.7.6, C11 6.7.7 */
Home |
Main Index |
Thread Index |
Old Index