Skip to content

Commit 6494bd2

Browse files
committed
genksyms: fix syntax error for attribute after 'union'
A longstanding issue with genksyms is that it has hidden syntax errors. When a syntax error occurs, yyerror() is called. However, error_with_pos() is a no-op unless the -w option is provided. You can observe syntax errors by manually passing the -w option. For example, with CONFIG_MODVERSIONS=y on v6.13-rc1: $ make -s KCFLAGS=-D__GENKSYMS__ fs/lockd/svc.i $ cat fs/lockd/svc.i | scripts/genksyms/genksyms -w [ snip ] ./include/net/addrconf.h:35: syntax error The syntax error occurs in the following code in include/net/addrconf.h: union __packed { [ snip ] }; The issue arises from __packed, which is defined as __attribute__((__packed__)), immediately after the 'union' keyword. This commit allows the 'union' keyword to be followed by attributes. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Nicolas Schier <n.schier@avm.de>
1 parent 82db1c2 commit 6494bd2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/genksyms/parse.y

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,16 @@ type_specifier:
236236
so that it is easier to expand the definition fully later. */
237237
| STRUCT_KEYW attribute_opt IDENT
238238
{ remove_node($1); (*$3)->tag = SYM_STRUCT; $$ = $3; }
239-
| UNION_KEYW IDENT
240-
{ remove_node($1); (*$2)->tag = SYM_UNION; $$ = $2; }
239+
| UNION_KEYW attribute_opt IDENT
240+
{ remove_node($1); (*$3)->tag = SYM_UNION; $$ = $3; }
241241
| ENUM_KEYW IDENT
242242
{ remove_node($1); (*$2)->tag = SYM_ENUM; $$ = $2; }
243243

244244
/* Full definitions of an s/u/e. Record it. */
245245
| STRUCT_KEYW attribute_opt IDENT class_body
246246
{ record_compound($1, $3, $4, SYM_STRUCT); $$ = $4; }
247-
| UNION_KEYW IDENT class_body
248-
{ record_compound($1, $2, $3, SYM_UNION); $$ = $3; }
247+
| UNION_KEYW attribute_opt IDENT class_body
248+
{ record_compound($1, $3, $4, SYM_UNION); $$ = $4; }
249249
| ENUM_KEYW IDENT enum_body
250250
{ record_compound($1, $2, $3, SYM_ENUM); $$ = $3; }
251251
/*
@@ -255,7 +255,7 @@ type_specifier:
255255
{ add_symbol(NULL, SYM_ENUM, NULL, 0); $$ = $2; }
256256
/* Anonymous s/u definitions. Nothing needs doing. */
257257
| STRUCT_KEYW attribute_opt class_body { $$ = $3; }
258-
| UNION_KEYW class_body { $$ = $2; }
258+
| UNION_KEYW attribute_opt class_body { $$ = $3; }
259259
;
260260

261261
simple_type_specifier:

0 commit comments

Comments
 (0)