Fixed #10380 (FP: misra-c2012-20.9)

This commit is contained in:
Daniel Marjamäki 2021-08-22 21:13:15 +02:00
parent 7fc145d076
commit e1d0db38ee
2 changed files with 13 additions and 0 deletions

View File

@ -3277,10 +3277,20 @@ class MisraChecker:
for cond in cfg.preprocessor_if_conditions:
if cond.E is None:
continue
defined = []
for directive in cfg.directives:
if directive.file == cond.file and directive.linenr == cond.linenr:
for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*\([ ]*([_a-zA-Z0-9]+)[ ]*\)', directive.str):
defined.append(name)
for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*([_a-zA-Z0-9]+)', directive.str):
defined.append(name)
break
for s in cond.E.split(' '):
if (s[0] >= 'A' and s[0] <= 'Z') or (s[0] >= 'a' and s[0] <= 'z'):
if isKeyword(s):
continue
if s in defined:
continue
self.reportError(cond, 20, 9)
def misra_20_10(self, data):

View File

@ -1388,6 +1388,9 @@ static void misra_15_6(void) {
do {} while (x<0); // no-warning
}
#if defined(M_20_9) && M_20_9 > 1 // no-warning (#10380)
#endif
static void misra_15_7(void) {
uint32_t var = 0;
uint32_t var2 = 0;