From 90550d24c42e1c6b24309df786895a1cc416df39 Mon Sep 17 00:00:00 2001 From: Georgy Komarov Date: Thu, 21 May 2020 09:34:28 +0300 Subject: [PATCH] misra.py: Fix crash on volatile macro argument (#2654) --- addons/misra.py | 2 ++ addons/test/misra/misra-test.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/addons/misra.py b/addons/misra.py index e9c48627b..dc9455d73 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1735,6 +1735,8 @@ class MisraChecker: if (not isConstantExpression(token)) or (not isUnsignedInt(token)): continue for value in token.values: + if value.intvalue is None: + continue if value.intvalue < 0 or value.intvalue > max_uint: self.reportError(token, 12, 4) break diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 8a7941bad..d3a7a1b52 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -473,6 +473,7 @@ void misra_12_3(int a, int b, int c) { // no warning #define MISRA12_4a 2000000000u #define MISRA12_4b 4000000000u +#define volatile_macro_12_4 (*(volatile U32 *) 0xFFFFFC10u) void misra_12_4() { uint32_t x; bool t; @@ -481,6 +482,7 @@ void misra_12_4() { x = 0u - 1u; // 12.4 x = t ? 0u : (0u-1u); // 12.4 x = 556200230913ULL; + foo(&volatile_macro_12_4); // no crash } struct misra_13_1_t { int a; int b; };