From 92b1fcdd4bed1c3ee1bdbac5dccbb4f4baa447b7 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 29 Jan 2018 11:26:22 +0100 Subject: Move sym.ranges check to end of _check_sym_sanity() More important stuff up front. --- kconfiglib.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index 621e6c3..80f13ff 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4201,23 +4201,6 @@ def _check_sym_sanity(sym): Checks various symbol properties that are handiest to check after parsing. Only generates errors and warnings. """ - if sym.ranges: - if not sym.orig_type in (INT, HEX): - sym.kconfig._warn( - "the {} symbol {} has ranges, but is not int or hex" - .format(TYPE_TO_STR[sym.orig_type], _name_and_loc_str(sym))) - else: - for low, high, _ in sym.ranges: - if not _int_hex_value_is_sane(low, sym.orig_type) or \ - not _int_hex_value_is_sane(high, sym.orig_type): - - sym.kconfig._warn("the {0} symbol {1} has a non-{0} range " - "[{2}, {3}]" - .format(TYPE_TO_STR[sym.orig_type], - _name_and_loc_str(sym), - _name_and_loc_str(low), - _name_and_loc_str(high))) - _check_select_imply_sanity(sym, sym.selects, "selects") _check_select_imply_sanity(sym, sym.implies, "implies") @@ -4242,6 +4225,25 @@ def _check_sym_sanity(sym): sym.kconfig._warn("{} defined without a type" .format(_name_and_loc_str(sym))) + + if sym.ranges: + if not sym.orig_type in (INT, HEX): + sym.kconfig._warn( + "the {} symbol {} has ranges, but is not int or hex" + .format(TYPE_TO_STR[sym.orig_type], _name_and_loc_str(sym))) + else: + for low, high, _ in sym.ranges: + if not _int_hex_value_is_sane(low, sym.orig_type) or \ + not _int_hex_value_is_sane(high, sym.orig_type): + + sym.kconfig._warn("the {0} symbol {1} has a non-{0} range " + "[{2}, {3}]" + .format(TYPE_TO_STR[sym.orig_type], + _name_and_loc_str(sym), + _name_and_loc_str(low), + _name_and_loc_str(high))) + + def _int_hex_value_is_sane(sym, type_): # 'not sym.nodes' implies a constant or undefined symbol, e.g. a plain # "123" -- cgit v1.2.3