Skip to content

Commit 2cb4c41

Browse files
authored
Fix #11443 (FP: misra-c2012-5.7 on anonymous struct) (cppcheck-opensource#5033)
1 parent 2bf2b7f commit 2cb4c41

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

addons/misra.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,8 @@ def _save_ctu_summary_tagnames(self, dumpfile, cfg):
13621362
for scope in cfg.scopes:
13631363
if scope.className is None:
13641364
continue
1365+
if scope.className.startswith('Anonymous'):
1366+
continue
13651367
if scope.type not in ('Struct', 'Enum'):
13661368
continue
13671369
used = False

addons/test/misra/misra-ctu-1-test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ struct misra_5_7_violation_t {
1717
};
1818
static misra_5_7_violation_t misra_5_7_use_type_1;
1919

20+
// #11443 - FP
21+
static struct
22+
{ // no warning
23+
uint16_t x;
24+
} misra_5_7_false_positive_1;
25+
2026
// cppcheck-suppress misra-c2012-8.4
2127
// cppcheck-suppress misra-c2012-5.8
2228
int misra_5_8_var1;

addons/test/misra/misra-ctu-2-test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ struct misra_5_7_violation_t {
1717
};
1818
static misra_5_7_violation_t misra_5_7_use_type_2;
1919

20+
// #11443 - FP
21+
static struct
22+
{ // no warning
23+
uint16_t x;
24+
} misra_5_7_false_positive_2;
25+
2026
// cppcheck-suppress misra-c2012-5.8
2127
static int misra_5_8_var1;
2228
// cppcheck-suppress misra-c2012-8.4

0 commit comments

Comments
 (0)