Fix misra addon rule 4 1 (#1846)

* Modifiy check for MISRA rule 4.1 to avoid skipping constant character literal enclosed by single quotes.
Add test for MISRA rule 4.1 which contains non-compliant cases defined by MISRA C 2012 document.

* Moved additional test cases for MISRA rule 4.1 to appropriate test case section.
This commit is contained in:
Mathias Schmid 2019-05-22 14:33:59 +02:00 committed by Daniel Marjamäki
parent e9aaa5edfa
commit 149c07f475
2 changed files with 3 additions and 1 deletions

View File

@ -631,7 +631,7 @@ class MisraChecker:
def misra_4_1(self, rawTokens):
for token in rawTokens:
if token.str[0] != '"':
if ((token.str[0] != '"') and (token.str[0] != '\'')):
continue
pos = 1
while pos < len(token.str) - 2:

View File

@ -63,6 +63,8 @@ int misra_5_2_field_hides_field1_31y;//5.2
};
const char *s41_1 = "\x41g"; // 4.1
const char *s41_2 = "\x41\x42";
int c41_3 = '\141t'; // 4.1
int c41_4 = '\141\t';
extern int misra_5_3_var_hides_var______31x;
void misra_5_3_var_hides_function_31x (void) {}