Fix crash in constPointer() (#4945)
This commit is contained in:
parent
7726a5b5b3
commit
63151f3291
|
@ -1478,7 +1478,7 @@ void CheckOther::checkConstVariable()
|
|||
else
|
||||
opTok = opTok->astOperand2();
|
||||
}
|
||||
if (opTok->valueType() && var->valueType() && opTok->valueType()->isConst(var->valueType()->pointer))
|
||||
if (opTok && opTok->valueType() && var->valueType() && opTok->valueType()->isConst(var->valueType()->pointer))
|
||||
continue;
|
||||
} else if (const Token* ftok = getTokenArgumentFunction(tok, argn)) {
|
||||
bool inconclusive{};
|
||||
|
|
|
@ -3486,6 +3486,12 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str()); // don't crash
|
||||
|
||||
check("void f(int& i) {\n"
|
||||
" int& r = i;\n"
|
||||
" if (!&r) {}\n"
|
||||
"}\n");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'r' can be declared as reference to const\n", "", errout.str()); // don't crash
|
||||
|
||||
check("class C;\n" // #11646
|
||||
"void g(const C* const p);\n"
|
||||
"void f(C* c) {\n"
|
||||
|
|
Loading…
Reference in New Issue