Skip to content

Commit f82790d

Browse files
authored
Fix #12362: False positive: misra 8.7: taking function by address is not recognized as function usage (#5920)
1 parent 593cf5f commit f82790d

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

addons/misra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ def _save_ctu_summary_usage(self, dumpfile, cfg):
15161516
for token in cfg.tokenlist:
15171517
if not token.isName:
15181518
continue
1519-
if token.function and token.scope.isExecutable:
1519+
if token.function and token != token.function.tokenDef:
15201520
if (not token.function.isStatic) and (token.str not in names):
15211521
names.append({'name': token.str, 'file': token.file})
15221522
elif token.variable:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ extern int misra_8_5;
4646
int32_t misra_8_6 = 1;
4747

4848
void misra_8_7_external(void) {}
49+
50+
// #12362
51+
void misra_8_7_compliant( void ){}
52+
static void misra_8_7_call(void) { misra_8_7_compliant(); }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ static void misra_8_7_caller(void) {
5656
misra_8_7_external();
5757
}
5858

59+
// #12362
60+
typedef void(*misra_8_7_func_ptr)( void );
61+
static const misra_8_7_func_ptr ptrs[] = { misra_8_7_compliant, NULL };

addons/test/misra/misra-ctu-test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ void misra_8_7_external(void);
1818
// cppcheck-suppress misra-c2012-2.5
1919
#define MISRA_2_5_VIOLATION 0
2020

21+
// #12362
22+
extern void misra_8_7_compliant( void );
2123

0 commit comments

Comments
 (0)