diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 08a812c27..003bc50ab 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -159,7 +159,7 @@ class ValueType: def __repr__(self): attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName", - "constness", "constness", "pointer"] + "constness", "pointer"] return "{}({})".format( "ValueType", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) @@ -198,7 +198,7 @@ class Token: isName Is this token a symbol name isNumber Is this token a number, for example 123, 12.34 isInt Is this token a int value such as 1234 - isFloat Is this token a int value such as 12.34 + isFloat Is this token a float value such as 12.34 isString Is this token a string literal such as "hello" strlen string length for string literal isChar Is this token a char literal such as 'x' diff --git a/addons/misra.py b/addons/misra.py index 997585261..19f26123c 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -24,6 +24,7 @@ import os import argparse import codecs import string +import copy try: from itertools import izip as zip @@ -340,30 +341,37 @@ def isStdLibId(id_, standard='c99'): # Reserved keywords defined in ISO/IEC9899:1990 -- ch 6.1.1 C90_KEYWORDS = { - 'auto', 'break', 'double', 'else', 'enum', 'extern', 'float', 'for', - 'goto', 'if', 'case', 'char', 'const', 'continue', 'default', 'do', 'int', - 'long', 'struct', 'switch', 'register', 'typedef', 'union', 'unsigned', - 'void', 'volatile', 'while', 'return', 'short', 'signed', 'sizeof', - 'static' + 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', + 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', + 'int', 'long', 'register', 'return', 'short', 'signed', + 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', + 'void', 'volatile', 'while' } # Reserved keywords defined in ISO/IEC 9899 WF14/N1256 -- ch. 6.4.1 -C99_KEYWORDS = { - 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', - 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'inline', - 'int', 'long', 'register', 'restrict', 'return', 'short', 'signed', - 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', - 'void', 'volatile', 'while', '_Bool', '_Complex', '_Imaginary' +C99_ADDED_KEYWORDS = { + 'inline', 'restrict', '_Bool', '_Complex', '_Imaginary', + 'bool', 'complex', 'imaginary' } +C11_ADDED_KEYWORDS = { + '_Alignas', '_Alignof', '_Atomic', '_Generic', '_Noreturn', + '_Statis_assert', '_Thread_local' , + 'alignas', 'alignof', 'noreturn', 'static_assert' +} def isKeyword(keyword, standard='c99'): kw_set = {} if standard == 'c89': kw_set = C90_KEYWORDS elif standard == 'c99': - kw_set = C99_KEYWORDS + kw_set = copy.copy(C90_KEYWORDS) + kw_set.update(C99_ADDED_KEYWORDS) + else: + kw_set = copy.copy(C90_KEYWORDS) + kw_set.update(C99_ADDED_KEYWORDS) + kw_set.update(C11_ADDED_KEYWORDS) return keyword in kw_set