Skip to content

Commit a23d4c2

Browse files
committed
genksyms: fix syntax error for attribute before init-declarator
A longstanding issue with genksyms is that it has hidden syntax errors. For example, genksyms fails to parse the following valid code: int x, __attribute__((__section__(".init.data")))y; Here, only 'y' is annotated by the attribute, although I am not aware of actual uses of this pattern in the kernel tree. 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. $ echo 'int x, __attribute__((__section__(".init.data")))y;' | scripts/genksyms/genksyms -w <stdin>:1: syntax error This commit allows attributes to be placed between a comma and init_declarator. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Nicolas Schier <n.schier@avm.de>
1 parent c825840 commit a23d4c2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/genksyms/parse.y

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ init_declarator_list:
173173
$$ = $1;
174174
dont_want_type_specifier = true;
175175
}
176-
| init_declarator_list ',' init_declarator
177-
{ struct string_list *decl = *$3;
178-
*$3 = NULL;
176+
| init_declarator_list ',' attribute_opt init_declarator
177+
{ struct string_list *decl = *$4;
178+
*$4 = NULL;
179179
free_list(*$2, NULL);
180180
*$2 = decl_spec;
181181

@@ -186,7 +186,7 @@ init_declarator_list:
186186
add_symbol(current_name,
187187
is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
188188
current_name = NULL;
189-
$$ = $3;
189+
$$ = $4;
190190
dont_want_type_specifier = true;
191191
}
192192
;

0 commit comments

Comments
 (0)