Skip to content

Commit 700e7a8

Browse files
committed
kconfig: turn missing prompt for choice members into error
Choice members must have a prompt; hence make it an error. While I was here, I moved the check to the parser to slim down _menu_finalize(). Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 8c00e58 commit 700e7a8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

scripts/kconfig/menu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice)
507507
menu->sym && !sym_is_choice_value(menu->sym)) {
508508
current_entry = menu;
509509
menu->sym->flags |= SYMBOL_CHOICEVAL;
510-
if (!menu->prompt)
511-
menu_warn(menu, "choice value must have a prompt");
512510
for (prop = menu->sym->prop; prop; prop = prop->next) {
513511
if (prop->type == P_DEFAULT)
514512
prop_warn(prop, "defaults for choice "

scripts/kconfig/parser.y

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ static bool zconf_endtoken(const char *tokenname,
3030

3131
struct menu *current_menu, *current_entry;
3232

33+
static bool inside_choice = false;
34+
3335
%}
3436

3537
%union
@@ -145,6 +147,14 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL
145147

146148
config_stmt: config_entry_start config_option_list
147149
{
150+
if (inside_choice) {
151+
if (!current_entry->prompt) {
152+
fprintf(stderr, "%s:%d: error: choice member must have a prompt\n",
153+
current_entry->filename, current_entry->lineno);
154+
yynerrs++;
155+
}
156+
}
157+
148158
printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
149159
};
150160

@@ -237,10 +247,14 @@ choice_entry: choice choice_option_list
237247
}
238248

239249
$$ = menu_add_menu();
250+
251+
inside_choice = true;
240252
};
241253

242254
choice_end: end
243255
{
256+
inside_choice = false;
257+
244258
if (zconf_endtoken($1, "choice")) {
245259
menu_end_menu();
246260
printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno);

0 commit comments

Comments
 (0)