diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-28 11:46:25 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-28 11:52:17 +0100 |
| commit | da0bfa3ad0eb616692f0edb6b5805097e059a259 (patch) | |
| tree | 1063a127488b395f4cefc77a4b68f162fd06e5d0 /kconfiglib.py | |
| parent | 9c309400fca07f15d8f4b116c12fa58f97d8043a (diff) | |
Error out for malformed hex/int/string defaults
Instead of failing in more cryptic ways later.
Also use 'orig_type' instead of 'type' for the UNKNOWN check. Oversight.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index e68e58f..362f099 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4168,11 +4168,25 @@ def _finalize_tree(node): def _check_sanity(sc): """ - Prints warnings for bad things that are easiest to check after parsing + Generates warnings or errors for bad things that are easiest to check after + parsing. sc: Symbol or Choice """ - if sc.type == UNKNOWN: + if sc.orig_type in (STRING, INT, HEX): + for sym, _ in sc.defaults: + if not isinstance(sym, Symbol) or \ + (sc.orig_type in (INT, HEX) and + (sym.is_constant or not sym.nodes) and + not _is_base_n(sym.str_value, _TYPE_TO_BASE[sc.orig_type])): + + raise KconfigSyntaxError( + "the {} symbol {} has a malformed default {}" + .format(TYPE_TO_STR[sc.orig_type], + _name_and_loc_str(sc), + expr_str(sym))) + + elif sc.orig_type == UNKNOWN: sc.kconfig._warn("{} defined without a type" .format(_name_and_loc_str(sc))) |
