Skip to content

Commit d7b8180

Browse files
committed
Fix #13615: False positive: Misra C 17.3: UINT32_C
1 parent 4e59e90 commit d7b8180

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: addons/misra.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,8 @@ def misra_17_3(self, cfg):
33383338
end_token = token.next.link
33393339
while tok != end_token:
33403340
if tok.isName and tok.function is None and tok.valueType is None and tok.next.str == "(" and \
3341-
tok.next.valueType is None and not isKeyword(tok.str) and not isStdLibId(tok.str):
3341+
tok.next.valueType is None and not isKeyword(tok.str) and not isStdLibId(tok.str) and \
3342+
not re.match(r'U?INT(_MAX|)(8|16|32|64)_C', tok.str):
33423343
self.reportError(tok, 17, 3)
33433344
break
33443345
tok = tok.next

Diff for: addons/test/misra/misra-test.c

+4
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,10 @@ static void misra_17_3(void) {
18091809
if (dostuff()) {}
18101810
}
18111811

1812+
static void misra_17_3_compliant(uint32_t x) {
1813+
if (x == UINT32_C(1)){ } // no warning for 17_3
1814+
}
1815+
18121816
static void misra_config(const char* str) {
18131817
if (strlen(str) > 3){} //10.4
18141818
if (sizeof(int) > 1){} //10.4

0 commit comments

Comments
 (0)