summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2025-01-13 18:00:53 +0300
committerMasahiro Yamada <masahiroy@kernel.org>2025-01-27 01:43:21 +0300
commit6494bd2d05f927fc0395c2ea11461517a9e0bb80 (patch)
treee6efa921872a3d11560c218147a8a4c6cdbb5730
parent82db1c29103ebf581484c0b30805e68726121dcb (diff)
downloadlinux-6494bd2d05f927fc0395c2ea11461517a9e0bb80.tar.xz
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>
-rw-r--r--scripts/genksyms/parse.y10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
index 33639232a709..a2cd035a78c9 100644
--- a/scripts/genksyms/parse.y
+++ b/scripts/genksyms/parse.y
@@ -236,16 +236,16 @@ type_specifier:
so that it is easier to expand the definition fully later. */
| STRUCT_KEYW attribute_opt IDENT
{ remove_node($1); (*$3)->tag = SYM_STRUCT; $$ = $3; }
- | UNION_KEYW IDENT
- { remove_node($1); (*$2)->tag = SYM_UNION; $$ = $2; }
+ | UNION_KEYW attribute_opt IDENT
+ { remove_node($1); (*$3)->tag = SYM_UNION; $$ = $3; }
| ENUM_KEYW IDENT
{ remove_node($1); (*$2)->tag = SYM_ENUM; $$ = $2; }
/* Full definitions of an s/u/e. Record it. */
| STRUCT_KEYW attribute_opt IDENT class_body
{ record_compound($1, $3, $4, SYM_STRUCT); $$ = $4; }
- | UNION_KEYW IDENT class_body
- { record_compound($1, $2, $3, SYM_UNION); $$ = $3; }
+ | UNION_KEYW attribute_opt IDENT class_body
+ { record_compound($1, $3, $4, SYM_UNION); $$ = $4; }
| ENUM_KEYW IDENT enum_body
{ record_compound($1, $2, $3, SYM_ENUM); $$ = $3; }
/*
@@ -255,7 +255,7 @@ type_specifier:
{ add_symbol(NULL, SYM_ENUM, NULL, 0); $$ = $2; }
/* Anonymous s/u definitions. Nothing needs doing. */
| STRUCT_KEYW attribute_opt class_body { $$ = $3; }
- | UNION_KEYW class_body { $$ = $2; }
+ | UNION_KEYW attribute_opt class_body { $$ = $3; }
;
simple_type_specifier: