Merge pull request #2718 from jubnzv/misra-fix-20-7-macro-expansion-fp

misra.py: Fix false positives for rule 20.7
This commit is contained in:
Daniel Marjamäki 2020-07-22 09:03:11 +02:00 committed by GitHub
commit ca3fae9afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -2322,7 +2322,9 @@ class MisraChecker:
while pos1 >= 0 and exp[pos1] == ' ': while pos1 >= 0 and exp[pos1] == ' ':
pos1 -= 1 pos1 -= 1
if exp[pos1] not in '([#,.': if exp[pos1] == '#':
continue
if exp[pos1] not in '([,.':
self.reportError(directive, 20, 7) self.reportError(directive, 20, 7)
break break
while pos2 < len(exp) and exp[pos2] == ' ': while pos2 < len(exp) and exp[pos2] == ' ':

View File

@ -1027,6 +1027,10 @@ union misra_19_2 { }; // 19.2
#define M_20_7_3(A) ((A)+A) // 20.7 #define M_20_7_3(A) ((A)+A) // 20.7
#define M_20_7_4(A) x##A // 20.10 this test was written to see there are not FPs #define M_20_7_4(A) x##A // 20.10 this test was written to see there are not FPs
#define M_20_7_5(A,B) f(A, B) // no warning #define M_20_7_5(A,B) f(A, B) // no warning
#define M_20_7_6(x) a ## x = ( x ) // 20.10
#define M_20_7_7(x) a = # x // 20.10
#define M_20_7_8(x, fn) a = fn ( # x ) // 20.7 20.10
#define M_20_7_9(x, fn) a = (fn) ( # x ) // 20.10
// Compliant: M is a structure member name, not an expression // Compliant: M is a structure member name, not an expression
struct { int a; } struct_20_7_s; struct { int a; } struct_20_7_s;