From 480d84d69ceaefa091baca11d8f209f537289c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Mar 2018 22:05:31 +0100 Subject: [PATCH] Fixed #8441 (MISRA Addon: FP 12.3 issued for initializer lists) --- addons/misra.py | 7 +++---- addons/test/misra-test.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 addons/test/misra-test.cpp diff --git a/addons/misra.py b/addons/misra.py index 659385de9..bf248f2a3 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -621,9 +621,9 @@ def misra_12_2(data): def misra_12_3(data): for token in data.tokenlist: - if token.str != ',' or token.scope.type == 'Enum': + if token.str != ',' or token.scope.type == 'Enum' or token.scope.type == 'Class' or token.scope.type == 'Global': continue - if token.astParent and token.astParent.str in {'(', ',', '{'}: + if token.astParent and token.astParent.str in ['(', ',', '{']: continue reportError(token, 12, 3) @@ -1072,6 +1072,7 @@ def loadRuleTexts(filename): num2 = 0 appendixA = False ruleText = False + global ruleTexts for line in open(filename, 'rt'): line = line.replace('\r', '').replace('\n', '') if len(line) == 0: @@ -1098,11 +1099,9 @@ def loadRuleTexts(filename): if ruleText: num2 = num2 + 1 num = num1 * 100 + num2 - global ruleTexts ruleTexts[num] = line ruleText = True elif ruleText and re.match(r'^[a-z].*', line): - global ruleTexts num = num1 * 100 + num2 ruleTexts[num] = ruleTexts[num] + ' ' + line continue diff --git a/addons/test/misra-test.cpp b/addons/test/misra-test.cpp new file mode 100644 index 000000000..ebf1905aa --- /dev/null +++ b/addons/test/misra-test.cpp @@ -0,0 +1,8 @@ + +// #8441 +class C { + int a; + int b; + C() : a(1), b(1) { c; } +}; +