kconfig: check prompt for choice while parsing
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 10 Mar 2024 13:45:15 +0000 (22:45 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 18 Mar 2024 17:30:51 +0000 (02:30 +0900)
This can be checked on-the-fly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/menu.c
scripts/kconfig/parser.y

index 840ce642ec439ee177e87a2caf9104601e712bbf..8498481e6afe36786b969efb6551528c1156ea05 100644 (file)
@@ -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;
index 22f616334585ba6f7bc29deedcd2e8287ecb2582..b45bfaf0a02b1234f49dd328a350a1de8f2641df 100644 (file)
@@ -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();
 };