Fix crashes on nullptr (#4575)
This commit is contained in:
parent
0d2993408a
commit
ffc0c57562
|
@ -697,7 +697,8 @@ void CheckClass::assignAllVarsVisibleFromScope(std::vector<Usage>& usageList, co
|
||||||
for (const Type::BaseInfo& i : scope->definedType->derivedFrom) {
|
for (const Type::BaseInfo& i : scope->definedType->derivedFrom) {
|
||||||
const Type *derivedFrom = i.type;
|
const Type *derivedFrom = i.type;
|
||||||
|
|
||||||
assignAllVarsVisibleFromScope(usageList, derivedFrom->classScope);
|
if (derivedFrom)
|
||||||
|
assignAllVarsVisibleFromScope(usageList, derivedFrom->classScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7634,6 +7634,8 @@ void Tokenizer::findGarbageCode() const
|
||||||
syntaxError(tok2, "Unexpected token '" + tok2->str() + "'");
|
syntaxError(tok2, "Unexpected token '" + tok2->str() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Token::Match(tok, "enum : %num%| {"))
|
||||||
|
syntaxError(tok->tokAt(2), "Unexpected token '" + tok->strAt(2) + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keywords in global scope
|
// Keywords in global scope
|
||||||
|
|
|
@ -656,7 +656,7 @@ static bool iscpp11init_impl(const Token * const tok)
|
||||||
if (!Token::Match(colonTok->tokAt(-1), "%name%|%num% :"))
|
if (!Token::Match(colonTok->tokAt(-1), "%name%|%num% :"))
|
||||||
return false;
|
return false;
|
||||||
const Token* caseTok = colonTok->tokAt(-2);
|
const Token* caseTok = colonTok->tokAt(-2);
|
||||||
while (Token::Match(caseTok->tokAt(-1), "::|%name%"))
|
while (caseTok && Token::Match(caseTok->tokAt(-1), "::|%name%"))
|
||||||
caseTok = caseTok->tokAt(-1);
|
caseTok = caseTok->tokAt(-1);
|
||||||
return Token::simpleMatch(caseTok, "case");
|
return Token::simpleMatch(caseTok, "case");
|
||||||
};
|
};
|
||||||
|
|
|
@ -1440,6 +1440,14 @@ private:
|
||||||
"[test.cpp:9]: (warning) Member variable 'B::ca' is not assigned a value in 'B::operator='.\n",
|
"[test.cpp:9]: (warning) Member variable 'B::ca' is not assigned a value in 'B::operator='.\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
check("class C : B {\n"
|
||||||
|
" virtual C& operator=(C& c);\n"
|
||||||
|
"};\n"
|
||||||
|
"class D : public C {\n"
|
||||||
|
" virtual C& operator=(C& c) { return C::operator=(c); };\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initvar_derived_pod_struct_with_union() {
|
void initvar_derived_pod_struct_with_union() {
|
||||||
|
|
|
@ -6759,6 +6759,9 @@ private:
|
||||||
|
|
||||||
// #9445 - typeof is not a keyword in C
|
// #9445 - typeof is not a keyword in C
|
||||||
ASSERT_NO_THROW(tokenizeAndStringify("void foo() { char *typeof, *value; }", false, Settings::Native, "test.c"));
|
ASSERT_NO_THROW(tokenizeAndStringify("void foo() { char *typeof, *value; }", false, Settings::Native, "test.c"));
|
||||||
|
|
||||||
|
ASSERT_THROW_EQUALS(tokenizeAndStringify("enum : { };"), InternalError, "syntax error: Unexpected token '{'");
|
||||||
|
ASSERT_THROW_EQUALS(tokenizeAndStringify("enum : 3 { };"), InternalError, "syntax error: Unexpected token '3'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue