summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-03-24 19:32:12 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-03-24 20:12:43 +0100
commit225ec4bc3e6a2b88e14d58522494950d9c9e8236 (patch)
tree0ad73865bbf459fd1696dce91659462945d94fc0
parent2195b37eb99f630a69e376d073cd58d3904b6420 (diff)
Warn if a choice symbol is selected or implied
This has no effect. Model the warning on the one for selecting a symbol with unsatisfied dependencies. This is a Kconfiglib-exclusive warning so far.
-rw-r--r--kconfiglib.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index c7fa862..ed945ca 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -4657,6 +4657,12 @@ def _check_choice_sanity(choice):
sym.kconfig._warn("default on the choice symbol {} will have "
"no effect".format(_name_and_loc(sym)))
+ if sym.rev_dep is not sym.kconfig.n:
+ _warn_choice_select_imply(sym, sym.rev_dep, "selected")
+
+ if sym.weak_rev_dep is not sym.kconfig.n:
+ _warn_choice_select_imply(sym, sym.weak_rev_dep, "implied")
+
for node in sym.nodes:
if node.parent.item is choice:
if not node.prompt:
@@ -4668,6 +4674,20 @@ def _check_choice_sanity(choice):
"prompt outside the choice"
.format(_name_and_loc(sym)))
+def _warn_choice_select_imply(sym, expr, expr_type):
+ msg = "the choice symbol {} is {} by the following symbols, which has " \
+ "no effect: ".format(_name_and_loc(sym), expr_type)
+
+ while isinstance(expr, tuple) and expr[0] == OR:
+ msg += _select_imply_str(expr[2])
+ expr = expr[1]
+
+ sym.kconfig._warn(msg + _select_imply_str(expr))
+
+def _select_imply_str(select):
+ return "\n - " + \
+ _name_and_loc(select[1] if isinstance(select, tuple) else select)
+
#
# Public global constants
#