Merge pull request #2733 from jubnzv/fix-20-7-multicharacter

misra.py: Fix 20.7 false positive for multi-character arguments
This commit is contained in:
Daniel Marjamäki 2020-08-10 11:07:10 +02:00 committed by GitHub
commit 20ded0b295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -2320,11 +2320,16 @@ class MisraChecker:
else: else:
state_in_string = True state_in_string = True
pos_search += 1 pos_search += 1
elif exp[pos_search] in directive_args: elif exp[pos_search].isalnum():
skip_next = True # Skip check for the next argument word = ""
break while pos_search < len(exp) and exp[pos_search].isalnum():
elif exp[pos_search] == arg: word += exp[pos_search]
pos_search += 1 pos_search += 1
if word == arg:
pos_search += 1
elif word in directive_args:
skip_next = True
break
elif exp[pos_search] == ' ': elif exp[pos_search] == ' ':
pos_search += 1 pos_search += 1
elif state_in_string: elif state_in_string:

View File

@ -1035,6 +1035,10 @@ union misra_19_2 { }; // 19.2
#define M_20_7_11(A, B, C) (A " " B " " C) #define M_20_7_11(A, B, C) (A " " B " " C)
#define M_20_7_12(A, B, C) (A " " B + C) // 20.7 #define M_20_7_12(A, B, C) (A " " B + C) // 20.7
#define M_20_7_13(A, B, C) (A + B " " C) // 20.7 #define M_20_7_13(A, B, C) (A + B " " C) // 20.7
#define M_20_7_14(STRING1, STRING2) (STRING1 " " STRING2)
#define M_20_7_15(STRING1, STRING2, STRING3) (STRING1 " " STRING2 " " STRING3)
#define M_20_7_16(STRING1, STRING2, STRING3) (STRING1 " " STRING2 + STRING3) // 20.7
#define M_20_7_17(STRING1, STRING2, STRING3) (STRING1 + STRING2 " " STRING3) // 20.7
// 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;