Module Name: src
Committed By: rillig
Date: Sat Jul 10 10:56:31 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_anon_struct.c
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: remove noclass_declmods from grammar
That rule was hard to understand since it contained clrtyp but not the
corresponding deftyp. It's easier to read when a grammar rule contains
both clrtyp and deftyp in the same line.
C99 does not mention the term 'decl-modifier' anywhere, and in fact the
only thing that this grammar rule allowed was a type-qualifier-list.
The new name better reflect this.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c
cvs rdiff -u -r1.286 -r1.287 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/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c:1.3 src/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c:1.4
--- src/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c:1.3 Sun Jan 31 14:39:31 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c Sat Jul 10 10:56:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_anon_struct.c,v 1.3 2021/01/31 14:39:31 rillig Exp $ */
+/* $NetBSD: d_c99_anon_struct.c,v 1.4 2021/07/10 10:56:31 rillig Exp $ */
# 3 "d_c99_anon_struct.c"
/* Anonymous struct test */
@@ -10,7 +10,7 @@ struct point {
int y;
};
-struct bar {
+struct rect {
struct {
struct point top_left;
struct point bottom_right;
@@ -22,7 +22,7 @@ struct bar {
int
main(void)
{
- struct bar b;
- b.top_left.x = 1;
+ struct rect r;
+ r.top_left.x = 1;
return 0;
}
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.286 src/usr.bin/xlint/lint1/cgram.y:1.287
--- src/usr.bin/xlint/lint1/cgram.y:1.286 Sat Jul 10 10:30:26 2021
+++ src/usr.bin/xlint/lint1/cgram.y Sat Jul 10 10:56:30 2021
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.286 2021/07/10 10:30:26 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.287 2021/07/10 10:56:30 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.286 2021/07/10 10:30:26 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.287 2021/07/10 10:56:30 rillig Exp $");
#endif
#include <limits.h>
@@ -675,12 +675,12 @@ member_declaration_list:
;
member_declaration:
- noclass_declmods deftyp {
+ clrtyp add_type_qualifier_list deftyp {
/* too late, i know, but getsym() compensates it */
symtyp = FMEMBER;
} notype_member_decls type_attribute_opt {
symtyp = FVFT;
- $$ = $4;
+ $$ = $5;
}
| noclass_declspecs deftyp {
symtyp = FMEMBER;
@@ -688,7 +688,7 @@ member_declaration:
symtyp = FVFT;
$$ = $4;
}
- | noclass_declmods deftyp type_attribute_opt {
+ | clrtyp add_type_qualifier_list deftyp type_attribute_opt {
symtyp = FVFT;
if (!Sflag)
/* anonymous struct/union members is a C9X feature */
@@ -733,8 +733,8 @@ noclass_declspecs_postfix:
clrtyp_typespec {
add_type($1);
}
- | noclass_declmods typespec {
- add_type($2);
+ | clrtyp add_type_qualifier_list typespec {
+ add_type($3);
}
| noclass_declspecs_postfix T_QUAL {
add_qualifier($2);
@@ -745,12 +745,14 @@ noclass_declspecs_postfix:
| noclass_declspecs_postfix type_attribute
;
-noclass_declmods:
- clrtyp T_QUAL {
- add_qualifier($2);
- }
- | noclass_declmods T_QUAL {
- add_qualifier($2);
+add_type_qualifier_list:
+ add_type_qualifier
+ | add_type_qualifier_list add_type_qualifier
+ ;
+
+add_type_qualifier:
+ T_QUAL {
+ add_qualifier($1);
}
;
@@ -1286,14 +1288,14 @@ type_name: /* C99 6.7.6 */
;
abstract_declaration:
- noclass_declmods deftyp {
+ clrtyp add_type_qualifier_list deftyp {
$$ = declare_1_abstract(abstract_name());
}
| noclass_declspecs deftyp {
$$ = declare_1_abstract(abstract_name());
}
- | noclass_declmods deftyp abstract_declarator {
- $$ = declare_1_abstract($3);
+ | clrtyp add_type_qualifier_list deftyp abstract_declarator {
+ $$ = declare_1_abstract($4);
}
| noclass_declspecs deftyp abstract_declarator {
$$ = declare_1_abstract($3);