From 880f496de29105614269ff032b62a040d0c8af34 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 21 Feb 2025 13:38:07 +0000 Subject: [PATCH] Fix #13648: False positive: Misra C 16.5: warn on default in macro --- addons/misra.py | 2 +- addons/test/misra/misra-test.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index bbf7e6c558e..2e160cd0bf5 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3231,7 +3231,7 @@ def misra_16_5(self, data): for token in data.tokenlist: if token.str != 'default': continue - if token.previous and token.previous.str == '{': + if token.previous and (token.previous.str == '{' or token.previous.str == '='): continue tok2 = token while tok2: diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 6e18e7610c5..b289b5c48de 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -2,6 +2,8 @@ // ~/cppcheck/cppcheck --dump misra/misra-test.h --std=c89 // ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump +#pragma ghs section rodata=default // no warning + #include "path\file.h" // 20.2 #include "file//.h" // 20.2 #include "file/*.h" // 20.2