MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / misra_6_1

Method misra_6_1

addons/misra.py:1999–2033  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

1997 self._save_ctu_summary_identifiers(dumpfile, cfg)
1998
1999 def misra_6_1(self, data):
2000 # Bitfield type must be bool or explicitly signed/unsigned int
2001 for token in data.tokenlist:
2002 if not token.valueType:
2003 continue
2004 if token.valueType.bits is None:
2005 continue
2006 if not token.variable:
2007 continue
2008 if not token.scope:
2009 continue
2010 if token.scope.type not in 'Struct':
2011 continue
2012
2013 if data.standards.c == 'c89':
2014 if token.valueType.type != 'int' and not isUnsignedType(token.variable.typeStartToken.str):
2015 self.reportError(token, 6, 1)
2016 elif data.standards.c in ('c99', 'c11', 'c17', 'c18'):
2017 if token.valueType.type == 'bool':
2018 continue
2019
2020 isExplicitlySignedOrUnsigned = False
2021 typeToken = token.variable.typeStartToken
2022 while typeToken:
2023 if typeToken.isUnsigned or typeToken.isSigned or isUnsignedType(typeToken.str):
2024 isExplicitlySignedOrUnsigned = True
2025 break
2026
2027 if typeToken is token.variable.typeEndToken:
2028 break
2029
2030 typeToken = typeToken.next
2031
2032 if not isExplicitlySignedOrUnsigned:
2033 self.reportError(token, 6, 1)
2034
2035
2036 def misra_6_2(self, data):

Callers

nothing calls this directly

Calls 2

reportErrorMethod · 0.95
isUnsignedTypeFunction · 0.85

Tested by

no test coverage detected