From 9c309400fca07f15d8f4b116c12fa58f97d8043a Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 28 Jan 2018 10:02:20 +0100 Subject: Add some post-parsing warnings These are easiest to check after parsing, since a symbol/choice can be defined in multiple locations: - Warn if a symbol or choice defined without a type. Also warn for choice value symbols defined without a type, even if they automatically get their type from the choice. This feature isn't well-known and probably not used deliberately. - Warn if a choice is defined without a prompt - Warn of a choice default symbol is not contained in the choice Also move _name_and_loc_str() from the symbol class to the global scope and generalize it to be able to handle choices. --- testsuite.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index a250c6e..083568d 100644 --- a/testsuite.py +++ b/testsuite.py @@ -801,19 +801,19 @@ g verify_locations(c.syms["SINGLE_DEF"].nodes, "tests/Klocation:4") verify_locations(c.syms["MULTI_DEF"].nodes, - "tests/Klocation:6", - "tests/Klocation:29", + "tests/Klocation:7", + "tests/Klocation:31", "tests/Klocation_included:3", - "tests/Klocation:45") + "tests/Klocation:47") verify_locations(c.named_choices["CHOICE"].nodes, "tests/Klocation_included:5") verify_locations([c.syms["MENU_HOOK"].nodes[0].next], - "tests/Klocation_included:10") + "tests/Klocation_included:12") verify_locations([c.syms["COMMENT_HOOK"].nodes[0].next], - "tests/Klocation_included:15") + "tests/Klocation_included:18") # Test recursive 'source' detection @@ -1520,7 +1520,11 @@ g print("Testing choice semantics") - c = Kconfig("Kconfiglib/tests/Kchoice") + # Would warn for choice value symbols defined without a type, even + # though the type is automatically derived. This is probably more + # helpful than ignoring those cases, as this feature isn't used + # deliberately anywhere from what I've seen. + c = Kconfig("Kconfiglib/tests/Kchoice", warn=False) for name in "BOOL", "BOOL_OPT", "BOOL_M", "DEFAULTS": verify(c.named_choices[name].orig_type == BOOL, -- cgit v1.2.3