Module Name: src
Committed By: rillig
Date: Sun Jul 25 19:57:22 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: merge duplicate code for abstract_declaration
No functional change; same code coverage outside of cgram.y.
To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 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.344 src/usr.bin/xlint/lint1/cgram.y:1.345
--- src/usr.bin/xlint/lint1/cgram.y:1.344 Sun Jul 25 19:27:26 2021
+++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 19:57:22 2021
@@ -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 @@ anonymize(sym_t *s)
%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 @@ type_name: /* C99 6.7.6 */
;
abstract_declaration: /* specific to lint */
- begin_type_qualifier_list end_type {
- $$ = declare_1_abstract(abstract_name());
- }
- | begin_type_specifier_qualifier_list end_type {
- $$ = declare_1_abstract(abstract_name());
- }
- | begin_type_qualifier_list end_type abstract_declarator {
+ begin_type_qualifier_list end_type abstract_declarator_opt {
$$ = declare_1_abstract($3);
}
- | begin_type_specifier_qualifier_list end_type abstract_declarator {
+ | begin_type_specifier_qualifier_list end_type
+ abstract_declarator_opt {
$$ = 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 */