diff --git a/addons/misra.py b/addons/misra.py index 2b2bea867..b3e193d39 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3231,6 +3231,14 @@ class MisraChecker: if d.expansionList.find('#') >= 0: self.reportError(directive, 20, 10) + def misra_20_11(self, cfg): + for directive in cfg.directives: + d = Define(directive) + for arg in d.args: + res = re.search(r'[^#]#[ ]*%s[ ]*##' % arg, ' ' + d.expansionList) + if res: + self.reportError(directive, 20, 11) + def misra_20_13(self, data): dir_pattern = re.compile(r'#[ ]*([^ (<]*)') for directive in data.directives: @@ -3904,6 +3912,7 @@ class MisraChecker: self.executeCheck(2008, self.misra_20_8, cfg) self.executeCheck(2009, self.misra_20_9, cfg) self.executeCheck(2010, self.misra_20_10, cfg) + self.executeCheck(2011, self.misra_20_11, cfg) self.executeCheck(2013, self.misra_20_13, cfg) self.executeCheck(2014, self.misra_20_14, cfg) self.executeCheck(2101, self.misra_21_1, cfg) diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index e83208a84..7693ed059 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -1569,6 +1569,8 @@ struct { int a; } struct_20_7_s; #define M_20_10(a) (#a) // 20.10 +#define M_20_11(a) # a ## 1 // 20.11 20.10 + #else1 // 20.13 #ifdef A