Fixed #11707 (False positive: misra 9.3 partial array initializations) (#5034)

This commit is contained in:
Daniel Marjamäki 2023-05-05 17:22:58 +02:00 committed by GitHub
parent 543b4adc8a
commit 4cf9a704b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -416,6 +416,13 @@ def misra_9_x(self, data, rule, rawTokens = None):
if rule == 902 and not ed.isMisra92Compliant():
self.reportError(nameToken, 9, 2)
if rule == 903 and not ed.isMisra93Compliant():
# Do not check when variable is pointer type
type_token = variable.nameToken
while type_token and type_token.isName:
type_token = type_token.previous
if type_token and type_token.str == '*':
continue
self.reportError(nameToken, 9, 3)
if rule == 904 and not ed.isMisra94Compliant():
self.reportError(nameToken, 9, 4)

View File

@ -408,6 +408,10 @@ enum misra_8_12_e { misra_e1 = sizeof(int), misra_e2}; // no-crash
static void misra_8_14(char * restrict str) {(void)str;} // 8.14
// #11707 -- false positive
struct S_9_3 { struct S_9_3* p; int x; };
struct S_9_3* s_9_3_array[] = { x, NULL }; // 8.4
static void misra_9_empty_or_zero_initializers(void) {
int a[2] = {}; // 9.2
int b[2][2] = {}; // 9.2