diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-28 19:35:48 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-28 19:35:48 +0100 |
| commit | 7432ade85dac70f2c0cdda1ea4e2cbc4830f73e4 (patch) | |
| tree | d9fe0069b35db2c17659b05121057d4db5dc1e69 | |
| parent | b9cdcb34ead2160dc9cfa5d30d949e4f18cb293f (diff) | |
Warn if a symbol is defined with multiple types
| -rw-r--r-- | kconfiglib.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 6ea71b4..4ecfae1 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1729,7 +1729,15 @@ class Kconfig(object): continue if t0 in _TYPE_TOKENS: - node.item.orig_type = _TOKEN_TO_TYPE[t0] + new_type = _TOKEN_TO_TYPE[t0] + + if node.item.orig_type != UNKNOWN and \ + node.item.orig_type != new_type: + self._warn("{} defined with multiple types, {} will be used" + .format(_name_and_loc_str(node.item), + TYPE_TO_STR[new_type])) + + node.item.orig_type = new_type if self._peek_token() is not None: prompt = (self._expect_str(), self._parse_cond()) @@ -1807,7 +1815,16 @@ class Kconfig(object): defaults.append((self._parse_expr(False), self._parse_cond())) elif t0 in (_T_DEF_BOOL, _T_DEF_TRISTATE): - node.item.orig_type = _TOKEN_TO_TYPE[t0] + new_type = _TOKEN_TO_TYPE[t0] + + if node.item.orig_type != UNKNOWN and \ + node.item.orig_type != new_type: + self._warn("{} defined with multiple types, {} will be used" + .format(_name_and_loc_str(node.item), + TYPE_TO_STR[new_type])) + + node.item.orig_type = new_type + defaults.append((self._parse_expr(False), self._parse_cond())) elif t0 == _T_PROMPT: |
