Fixed #8822 (false positive: MISRA rule 13.4)

This commit is contained in:
Daniel Marjamäki 2019-04-27 17:43:26 +02:00
parent 004d7d5333
commit 48dfba429a
2 changed files with 13 additions and 1 deletions

View File

@ -1261,7 +1261,7 @@ class MisraChecker:
continue
if token.astOperand1.str == '[' and token.astOperand1.previous.str in {'{', ','}:
continue
if not (token.astParent.str in [',', ';']):
if not (token.astParent.str in [',', ';', '{']):
self.reportError(token, 13, 4)

View File

@ -267,6 +267,18 @@ void misra_13_3() {
x = y++; // 13.3
}
#define STRING_DEF_13_4 "This is a string"
typedef struct
{
char string[sizeof(STRING_DEF_13_4)];
} s13_4_t;
static s13_4_t s13_4 =
{
.string = STRING_DEF_13_4 // no-warning
};
void misra_13_4() {
if (x != (y = z)) {} // 13.4
else {}