misra.py: Fix crash on volatile macro argument (#2654)
This commit is contained in:
parent
9861a5291e
commit
90550d24c4
|
@ -1735,6 +1735,8 @@ class MisraChecker:
|
||||||
if (not isConstantExpression(token)) or (not isUnsignedInt(token)):
|
if (not isConstantExpression(token)) or (not isUnsignedInt(token)):
|
||||||
continue
|
continue
|
||||||
for value in token.values:
|
for value in token.values:
|
||||||
|
if value.intvalue is None:
|
||||||
|
continue
|
||||||
if value.intvalue < 0 or value.intvalue > max_uint:
|
if value.intvalue < 0 or value.intvalue > max_uint:
|
||||||
self.reportError(token, 12, 4)
|
self.reportError(token, 12, 4)
|
||||||
break
|
break
|
||||||
|
|
|
@ -473,6 +473,7 @@ void misra_12_3(int a, int b, int c) { // no warning
|
||||||
|
|
||||||
#define MISRA12_4a 2000000000u
|
#define MISRA12_4a 2000000000u
|
||||||
#define MISRA12_4b 4000000000u
|
#define MISRA12_4b 4000000000u
|
||||||
|
#define volatile_macro_12_4 (*(volatile U32 *) 0xFFFFFC10u)
|
||||||
void misra_12_4() {
|
void misra_12_4() {
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
bool t;
|
bool t;
|
||||||
|
@ -481,6 +482,7 @@ void misra_12_4() {
|
||||||
x = 0u - 1u; // 12.4
|
x = 0u - 1u; // 12.4
|
||||||
x = t ? 0u : (0u-1u); // 12.4
|
x = t ? 0u : (0u-1u); // 12.4
|
||||||
x = 556200230913ULL;
|
x = 556200230913ULL;
|
||||||
|
foo(&volatile_macro_12_4); // no crash
|
||||||
}
|
}
|
||||||
|
|
||||||
struct misra_13_1_t { int a; int b; };
|
struct misra_13_1_t { int a; int b; };
|
||||||
|
|
Loading…
Reference in New Issue