Tokenizer::setVarId: Fixed hang when checking libgc

This commit is contained in:
Daniel Marjamäki 2013-11-15 16:16:22 +01:00
parent 5af2fe6e5b
commit 30720affd6
2 changed files with 7 additions and 1 deletions

View File

@ -6355,7 +6355,7 @@ bool Tokenizer::simplifyKnownVariables()
std::string(tok2->strAt(-2) + " .") :
std::string("");
if (tok2->str() == tok2->strAt(2))
if (Token::Match(tok2, "%varid% = &| %varid%", tok2->varId()))
continue;
const Token * const valueToken = tok2->tokAt(2);

View File

@ -251,6 +251,7 @@ private:
TEST_CASE(varid51); // don't set varid for template function
TEST_CASE(varid52); // Set varid for nested templates
TEST_CASE(varid53); // #4172 - Template instantiation: T<&functionName> list[4];
TEST_CASE(varid54); // hang
TEST_CASE(varid_cpp_keywords_in_c_code);
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
@ -3882,6 +3883,11 @@ private:
tokenizeDebugListing("A<&f> list[4];", false, "test.cpp"));
}
void varid54() { // hang
// Original source code: libgc
tokenizeDebugListing("STATIC ptr_t GC_approx_sp(void) { word sp; sp = (word)&sp; return((ptr_t)sp); }",true);
}
void varid_cpp_keywords_in_c_code() {
const char code[] = "void f() {\n"
" delete d;\n"