Skip to content

Commit

Permalink
Fix #12978: false positive : Misra C 8.4: extern variables with struc…
Browse files Browse the repository at this point in the history
…ts (#6655)
  • Loading branch information
swasti16 committed Aug 2, 2024
1 parent 86cedde commit 8ffd0c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ def misra_8_4(self, cfg):
continue
tok = var.nameToken
if tok.next.str == ";":
if tok.next.isSplittedVarDeclEq or (tok.valueType and tok.valueType.type == "record"):
if tok.next.isSplittedVarDeclEq:
self.insert_in_dict(extern_var_with_def, tok.str, tok)
else:
self.insert_in_dict(extern_var_without_def, tok.str, tok)
Expand Down
2 changes: 2 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ uint8_t misra_8_4_pressure = 101u; //8.4
int32_t misra_8_4_ext_val2;
int32_t misra_8_4_ext_val2 = 3; // compliant
int32_t misra_8_4_ext_val4; //8.4
// #12978
const stError_t * m8_4_pubTestPointer; //compliant

static int32_t misra_8_8 = 123;
extern int32_t misra_8_8; // 8.8
Expand Down
6 changes: 6 additions & 0 deletions addons/test/misra/misra-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ struct misra_h_s { int foo; };
bool test(char *a); // OK
int misra_8_2_no_fp(int a);
void misra_8_4_bar(void);
// #12978
typedef struct m8_4_stErrorDef
{
uint8_t ubReturnVal;
} m8_4_stErrorDef;
extern const m8_4_stErrorDef * m8_4_pubTestPointer;
#endif // MISRA_TEST_H

0 comments on commit 8ffd0c1

Please sign in to comment.