Fix #11443 (FP: misra-c2012-5.7 on anonymous struct) (#5033)

This commit is contained in:
Daniel Marjamäki 2023-05-07 20:22:26 +02:00 committed by GitHub
parent 2bf2b7fb44
commit 2cb4c4126a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -1362,6 +1362,8 @@ class MisraChecker:
for scope in cfg.scopes:
if scope.className is None:
continue
if scope.className.startswith('Anonymous'):
continue
if scope.type not in ('Struct', 'Enum'):
continue
used = False

View File

@ -17,6 +17,12 @@ struct misra_5_7_violation_t {
};
static misra_5_7_violation_t misra_5_7_use_type_1;
// #11443 - FP
static struct
{ // no warning
uint16_t x;
} misra_5_7_false_positive_1;
// cppcheck-suppress misra-c2012-8.4
// cppcheck-suppress misra-c2012-5.8
int misra_5_8_var1;

View File

@ -17,6 +17,12 @@ struct misra_5_7_violation_t {
};
static misra_5_7_violation_t misra_5_7_use_type_2;
// #11443 - FP
static struct
{ // no warning
uint16_t x;
} misra_5_7_false_positive_2;
// cppcheck-suppress misra-c2012-5.8
static int misra_5_8_var1;
// cppcheck-suppress misra-c2012-8.4