From f01ffddca65b2ab40aa871a5ea8c3c3d4abd4e5c Mon Sep 17 00:00:00 2001 From: Dani Martin <32535596+danimartin82@users.noreply.github.com> Date: Wed, 22 Sep 2021 19:25:02 +0200 Subject: [PATCH] Fix in MISRA rule 6.1 check (#3458) --- addons/misra.py | 4 ++-- addons/test/misra/misra-test.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index a8139ca21..ae5855dbc 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1693,7 +1693,7 @@ class MisraChecker: continue if data.standards.c == 'c89': - if token.valueType.type != 'int': + if token.valueType.type != 'int' and not isUnsignedType(token.variable.typeStartToken.str): self.reportError(token, 6, 1) elif data.standards.c == 'c99': if token.valueType.type == 'bool': @@ -1702,7 +1702,7 @@ class MisraChecker: isExplicitlySignedOrUnsigned = False typeToken = token.variable.typeStartToken while typeToken: - if typeToken.isUnsigned or typeToken.isSigned: + if typeToken.isUnsigned or typeToken.isSigned or isUnsignedType(typeToken.str): isExplicitlySignedOrUnsigned = True break diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 24604979b..d5dbf9a62 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -252,6 +252,7 @@ struct struct_with_bitfields signed long f:2; // 6.1 - signed long not compliant unsigned int g:1; // Compliant signed int h:1; // 6.2 - signed int with size 1 is not compliant + uint16_t i:1; // Compliant }; static void misra6_1_fn(void) {