This commit is contained in:
parent
c3136dbc2a
commit
204e75dc59
|
@ -1457,6 +1457,15 @@ class MisraChecker:
|
|||
cppcheckdata.reportSummary(dumpfile, 'MisraUsage', names)
|
||||
|
||||
|
||||
def misra_1_2(self, cfg):
|
||||
# gcc language extensions: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
|
||||
for token in cfg.tokenlist:
|
||||
if simpleMatch(token, '? :'):
|
||||
self.reportError(token, 1, 2)
|
||||
elif simpleMatch(token, '( {') and simpleMatch(token.next.link.previous, '; } )'):
|
||||
self.reportError(token, 1, 2)
|
||||
|
||||
|
||||
def misra_1_4(self, cfg):
|
||||
for token in cfg.tokenlist:
|
||||
if token.str in ('_Atomic', '_Noreturn', '_Generic', '_Thread_local', '_Alignas', '_Alignof'):
|
||||
|
@ -4311,6 +4320,7 @@ class MisraChecker:
|
|||
if not self.settings.quiet:
|
||||
self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name))
|
||||
|
||||
self.executeCheck(102, self.misra_1_2, cfg)
|
||||
if not path_premium_addon:
|
||||
self.executeCheck(104, self.misra_1_4, cfg)
|
||||
self.executeCheck(202, self.misra_2_2, cfg)
|
||||
|
|
|
@ -58,6 +58,12 @@ typedef unsigned int u32;
|
|||
typedef signed int s32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
static void misra_1_2(void)
|
||||
{
|
||||
(void)(condition ? : 0); // 1.2
|
||||
a = 1 + ({if (!expr) {code;} 1;}); // 1.2
|
||||
}
|
||||
|
||||
static _Atomic int misra_1_4_var; // 1.4
|
||||
static _Noreturn void misra_1_4_func(void) // 1.4
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue