Fixed #5867 (invalid debug warnung: Scope::checkVariable : varid0)

This commit is contained in:
Robert Reif 2014-06-02 06:18:32 +02:00 committed by Daniel Marjamäki
parent ad1662a201
commit e5ae575ace
2 changed files with 14 additions and 1 deletions

View File

@ -2612,7 +2612,7 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const
typetok = localTypeTok;
} else if ((isLocal() || type == Scope::eFunction) &&
Token::Match(localVarTok, "%var% (") &&
Token::simpleMatch(localVarTok->next()->link(), ") ;")) {
Token::simpleMatch(localVarTok->next()->link(), ") ;") && localVarTok->varId()) {
vartok = localVarTok;
typetok = localTypeTok;
} else if (type == eCatch &&

View File

@ -245,6 +245,8 @@ private:
TEST_CASE(varTypesIntegral); // known integral
TEST_CASE(varTypesFloating); // known floating
TEST_CASE(varTypesOther); // (un)known
TEST_CASE(functionPrototype); // ticket #5867
}
void array() const {
@ -2402,6 +2404,17 @@ private:
ASSERT_EQUALS(false, b->isFloatingType());
}
}
void functionPrototype() {
check("int foo(int x) {\n"
" extern int func1();\n"
" extern int func2(int);\n"
" int func3();\n"
" int func4(int);\n"
" return func4(x);\n"
"}\n", true);
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestSymbolDatabase)