Fix #12184: false positive: misra 11.6, cast expression '0U' to 'void*' (#5666)

This commit is contained in:
Swasti Shrivastava 2023-11-16 13:36:58 +05:30 committed by GitHub
parent ae3f7bd800
commit 81a03e7341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -2562,7 +2562,7 @@ class MisraChecker:
vt2 = token.astOperand1.valueType
if not vt1 or not vt2:
continue
if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.str != "0":
if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.getKnownIntValue() != 0:
self.reportError(token, 11, 6)
elif vt1.pointer == 0 and vt1.type != 'void' and vt2.pointer == 1 and vt2.type == 'void':
self.reportError(token, 11, 6)

View File

@ -811,6 +811,8 @@ static void misra_11_6(void) {
x = (u64)p; // 11.6
p = ( void * )0; // no-warning
(void)p; // no-warning
// # 12184
p = (void*)0U; // no-warning
}