diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-04-06 16:41:01 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-04-06 16:59:24 +0200 |
| commit | e8408a06c68d87485a9d45817dfdd60e722a6f1c (patch) | |
| tree | 08ef606faa6f8aacb30e0a5e6212d5952cffb76e | |
| parent | 981d24aff765794f4ab440f29b1543a118222357 (diff) | |
Move sanity checking to after _finalize_tree()
Previously, the warnings
warning: FOO (defined at Kconfig:1, Kconfig:6) defined with type unknown
warning: the default selection BAR (defined at Kconfig:9) of FOO (defined at Kconfig:1, Kconfig:6) is not contained in the choice
were printed for this (obscure, but okay) pair of definitions:
choice FOO
default BAR
endchoice
choice FOO
prompt "foo"
config BAR
bool "bar"
endchoice
The problem is that BAR is not known to be a choice symbol by the time
the first choice definition is encountered in _finalize_tree(), since
that's determined only when the second definition is encountered (it
needs to happen there, because implicit submenus can influence whether a
symbol is a choice symbol or not, and implicit submenus are determined
in _finalize_tree()).
Fix it by moving the sanity checks out of _finalize_tree() and into a
separate pass over all symbols and choices that runs after
_finalize_tree(). That might avoid other gotchas too.
| -rw-r--r-- | kconfiglib.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 8e5d9b1..d9cd4f0 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -589,7 +589,7 @@ class Kconfig(object): self.const_syms = {} self.defined_syms = [] self.named_choices = {} - # Used for quickly invalidating all choices + # List containing all choices. Not sure it's helpful to expose this. self._choices = [] for nmy in "n", "m", "y": @@ -669,6 +669,17 @@ class Kconfig(object): # Do various post-processing of the menu tree _finalize_tree(self.top_node) + + # Do sanity checks. Some of these depend on everything being + # finalized. + + for sym in self.defined_syms: + _check_sym_sanity(sym) + + for choice in self._choices: + _check_choice_sanity(choice) + + # Build Symbol._dependents for all symbols self._build_dep() @@ -4539,8 +4550,6 @@ def _finalize_tree(node): node.next = cur.next cur.next = None - _check_sym_sanity(node.item) - if node.list: # We have a node with child nodes where the child nodes are now @@ -4552,7 +4561,6 @@ def _finalize_tree(node): # Empty choices (node.list None) are possible, so this needs to go outside if isinstance(node.item, Choice): _finalize_choice(node) - _check_choice_sanity(node.item) def _check_sym_sanity(sym): # Checks various symbol properties that are handiest to check after |
