diff --git a/addons/misra-test.c b/addons/misra-test.c index 57025b8c4..168ec4d85 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -10,6 +10,11 @@ typedef unsigned char u8; +void misra_4_3() { + dostuff(); + asm("abc"); // 4.3 +} + void misra_5_1() { int a123456789012345678901234567890; // no-warning int a1234567890123456789012345678901; // 5.1 diff --git a/addons/misra.py b/addons/misra.py index b93f70361..191ca61e8 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -235,6 +235,13 @@ def findInclude(rawTokens, header): return headerToken return None +def misra_4_3(data): + for token in data.tokenlist: + if not simpleMatch(token, 'asm ('): + continue + if token.scope.type != 'Function' or (not token.previous) or token.previous.str != '{' or (not simpleMatch(token.next.link, ') ; }')): + reportError(token, 4, 3) + def misra_5_1(data): for token in data.tokenlist: if token.isName and len(token.str) > 31: @@ -716,6 +723,7 @@ for arg in sys.argv[1:]: if len(data.configurations) > 1: print('Checking ' + arg + ', config "' + cfg.name + '"...') + misra_4_3(cfg) misra_5_1(cfg) if cfgNumber == 1: misra_7_1(data.rawTokens)