Misra: Add rule 19.2

This commit is contained in:
Daniel Marjamäki 2017-04-14 21:14:26 +02:00
parent e3872f9718
commit 87d0fdd709
2 changed files with 10 additions and 0 deletions

View File

@ -190,3 +190,6 @@ void misra_18_8(int x) {
int buf2[sizeof(int)]; int buf2[sizeof(int)];
int vla[x]; // 18.8 int vla[x]; // 18.8
} }
union misra_19_2 { }; // 19.2

View File

@ -545,6 +545,12 @@ def misra_18_8(data):
if not isConstantExpression(typetok.astOperand2): if not isConstantExpression(typetok.astOperand2):
reportError(var.nameToken, 18, 8) reportError(var.nameToken, 18, 8)
def misra_19_2(data):
for token in data.tokenlist:
if token.str == 'union':
reportError(token, 19, 2)
if '-verify' in sys.argv[1:]: if '-verify' in sys.argv[1:]:
VERIFY = True VERIFY = True
@ -609,6 +615,7 @@ for arg in sys.argv[1:]:
misra_17_8(cfg) misra_17_8(cfg)
misra_18_5(cfg) misra_18_5(cfg)
misra_18_8(cfg) misra_18_8(cfg)
misra_19_2(cfg)
if VERIFY: if VERIFY:
for expected in VERIFY_EXPECTED: for expected in VERIFY_EXPECTED: