Skip to contentSkip to conversation

kconfig: check prompt for choice while parsing

PATCH New Masahiro Yamada 1 participant 1 message Mar 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: check prompt for choice while parsing

This can be checked on-the-fly.

---

 scripts/kconfig/menu.c   | 3 ---
 scripts/kconfig/parser.y | 6 ++++++
 2 files changed, 6 insertions(+), 3 deletions(-)
scripts/kconfig/menu.c +0 -3
index 840ce642ec43..8498481e6afe 100644
@@ -561,9 +561,6 @@ void menu_finalize(struct menu *parent)
 		if (sym->type == S_UNKNOWN)
 			menu_warn(parent, "config symbol defined without type");
 
-		if (sym_is_choice(sym) && !parent->prompt)
-			menu_warn(parent, "choice must have a prompt");
-
 		/* Check properties connected to this symbol */
 		sym_check_prop(sym);
 		sym->flags |= SYMBOL_WARNED;
scripts/kconfig/parser.y +6 -0
index 22f616334585..b45bfaf0a02b 100644
@@ -233,6 +233,12 @@ choice: T_CHOICE T_EOL
 
 choice_entry: choice choice_option_list
 {
+	if (!current_entry->prompt) {
+		fprintf(stderr, "%s:%d: error: choice must have a prompt\n",
+			current_entry->filename, current_entry->lineno);
+		yynerrs++;
+	}
+
 	$$ = menu_add_menu();
 };
 
Signature · 1 line
2.40.1