parent
a0b22410cf
commit
3ff7ef0918
|
@ -1611,6 +1611,18 @@ class MisraChecker:
|
|||
if var and var.isArgument:
|
||||
self.reportError(token, 17, 8)
|
||||
|
||||
def misra_18_4(self, data):
|
||||
for token in data.tokenlist:
|
||||
if not token.str in ('+', '-', '+=', '-='):
|
||||
continue
|
||||
if token.astOperand1 is None or token.astOperand2 is None:
|
||||
continue
|
||||
vt1 = token.astOperand1.valueType
|
||||
vt2 = token.astOperand2.valueType
|
||||
if vt1 and vt1.pointer > 0:
|
||||
self.reportError(token, 18, 4)
|
||||
elif vt2 and vt2.pointer > 0:
|
||||
self.reportError(token, 18, 4)
|
||||
|
||||
def misra_18_5(self, data):
|
||||
for var in data.variables:
|
||||
|
@ -2304,6 +2316,7 @@ class MisraChecker:
|
|||
self.misra_17_6(data.rawTokens)
|
||||
self.misra_17_7(cfg)
|
||||
self.misra_17_8(cfg)
|
||||
self.misra_18_4(cfg)
|
||||
self.misra_18_5(cfg)
|
||||
self.misra_18_7(cfg)
|
||||
self.misra_18_8(cfg)
|
||||
|
|
|
@ -503,6 +503,20 @@ void misra_17_8(int x) {
|
|||
x = 3; // 17.8
|
||||
}
|
||||
|
||||
void misra_18_4()
|
||||
{
|
||||
int b = 42;
|
||||
int *bp = &b;
|
||||
bp += 1; // 18.4
|
||||
bp -= 2; // 18.4
|
||||
int *p = bp - 2; // 18.4
|
||||
int *ab = &b + 1; // 18.4
|
||||
p = bp + p; // 18.4
|
||||
bp = 1 + p + 1; // 18.4
|
||||
b += 19; // no-warning
|
||||
b = b + 9; // no-warning
|
||||
}
|
||||
|
||||
void misra_18_5() {
|
||||
int *** p; // 18.5
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue