Fixed ticket #3310 (segmentation fault of cppcheck)
This commit is contained in:
parent
3abece027e
commit
a546fc6e9d
|
@ -4170,7 +4170,7 @@ bool Tokenizer::simplifyTokenList()
|
|||
}
|
||||
}
|
||||
|
||||
/* // Replace "&str[num]" => "(str + num)"
|
||||
// Replace "&str[num]" => "(str + num)"
|
||||
//TODO: fix the fails testrunner reports:
|
||||
//1)
|
||||
//test/teststl.cpp:805: Assertion failed.
|
||||
|
@ -4184,7 +4184,7 @@ bool Tokenizer::simplifyTokenList()
|
|||
//"[test.cpp:4]: (error) Return of the address of an auto-variable\n".
|
||||
//Actual:
|
||||
//"".
|
||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||
/*for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||
if ((Token::Match(tok->next(), "& %var% [ %num% ]") ||
|
||||
Token::Match(tok->next(), "& %var% [ %var% ]"))) {
|
||||
tok = tok->next();
|
||||
|
@ -9674,13 +9674,17 @@ void Tokenizer::removeUnnecessaryQualification()
|
|||
}
|
||||
|
||||
while (tok1 && tok1->str() != "(") {
|
||||
if (tok1->str() == ";")
|
||||
break;
|
||||
tok1 = tok1->next();
|
||||
++offset;
|
||||
}
|
||||
if (!tok1 || tok1->str() != "(")
|
||||
continue;
|
||||
} else if (tok->strAt(2) == "~")
|
||||
++offset;
|
||||
|
||||
if (Token::Match(tok->tokAt(offset)->link(), ") const| {|;|:")) {
|
||||
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset)->link(), ") const| {|;|:")) {
|
||||
std::string qualification = tok->str() + "::";
|
||||
|
||||
// check for extra qualification
|
||||
|
|
|
@ -386,6 +386,7 @@ private:
|
|||
TEST_CASE(removeUnnecessaryQualification7); // ticket #2970
|
||||
TEST_CASE(removeUnnecessaryQualification8);
|
||||
TEST_CASE(removeUnnecessaryQualification9); // ticket #3151
|
||||
TEST_CASE(removeUnnecessaryQualification10); // ticket #3310 segmentation fault
|
||||
|
||||
TEST_CASE(simplifyIfNotNull);
|
||||
TEST_CASE(simplifyVarDecl1); // ticket # 2682 segmentation fault
|
||||
|
@ -7420,6 +7421,16 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification10() {
|
||||
const char code[] = "template<typename T> class A\n"
|
||||
"{\n"
|
||||
" operator T();\n"
|
||||
" A() { T (A::*f)() = &A::operator T; }\n"
|
||||
"};\n";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyIfNotNull() {
|
||||
{
|
||||
// ticket # 2601 segmentation fault
|
||||
|
|
Loading…
Reference in New Issue