diff --git a/addons/misra.py b/addons/misra.py index 27314b4eb..34495fc70 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1308,7 +1308,7 @@ def misra_20_14(data): elif directive.str == '#endif': if len(ifStack) == 0: reportError(directive, 20, 14) - elif directive.file != ifStack[-1].file: + elif directive.file != ifStack[-1].file: reportError(directive, 20, 14) ifStack.pop() @@ -1330,6 +1330,15 @@ def misra_21_5(data): reportError(directive, 21, 5) +def misra_21_6(data): + dir_stdio = findInclude(data.directives, '') + dir_wchar = findInclude(data.directives, '') + if dir_stdio: + reportError(dir_stdio, 21, 6) + if dir_wchar: + reportError(dir_wchar, 21, 6) + + def misra_21_7(data): for token in data.tokenlist: if isFunctionCall(token) and (token.astOperand1.str in {'atof', 'atoi', 'atol', 'atoll'}): @@ -1348,6 +1357,16 @@ def misra_21_9(data): reportError(token, 21, 9) +def misra_21_10(data): + directive = findInclude(data.directives, '') + if directive: + reportError(directive, 21, 10) + + for token in data.tokenlist: + if (token.str == 'wcsftime') and token.next and token.next.str == '(': + reportError(token, 21, 10) + + def misra_21_11(data): directive = findInclude(data.directives, '') if directive: @@ -1603,9 +1622,11 @@ for arg in sys.argv[1:]: misra_21_3(cfg) misra_21_4(cfg) misra_21_5(cfg) + misra_21_6(cfg) misra_21_7(cfg) misra_21_8(cfg) misra_21_9(cfg) + misra_21_10(cfg) misra_21_11(cfg) # 22.4 is already covered by Cppcheck writeReadOnlyFile if VERIFY: diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index d58aec43e..3d8d30c82 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -5,8 +5,12 @@ #include /*abc*/ "file.h" // 20.3 #include // 21.4 #include // 21.5 +#include //21.6 +#include //21.6 +#include // 21.10 #include // 21.11 + typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32;