From 0eadd61c05c523a150721f9646e4d3f7cff58e5c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 30 Jan 2018 10:43:04 +0100 Subject: Warn if choice symbol has prompt outside choice Defining a choice symbol in multiple places to add some properties to it outside the choice seems to actually be done deliberately by MIPS, but it's almost guaranteed to be an error if the definition(s) outside the choice have a prompt (and so can be changed by the user there), so warn for that. --- kconfiglib.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index 3f1710c..c7c34bc 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4319,12 +4319,15 @@ def _check_choice_sanity(choice): .format(_name_and_loc_str(sym))) for node in sym.nodes: - if node.prompt: - break - else: - choice.kconfig._warn("the choice symbol {} has no prompt" - .format(_name_and_loc_str(sym))) - + if node.parent.item is choice: + if not node.prompt: + choice.kconfig._warn("the choice symbol {} has no prompt" + .format(_name_and_loc_str(sym))) + + elif node.prompt: + choice.kconfig._warn("the choice symbol {} is defined with a " + "prompt outside the choice" + .format(_name_and_loc_str(sym))) # # Public global constants -- cgit v1.2.3