Fixed #3799 (Bug: Function gets varId)
This commit is contained in:
parent
06a77679d4
commit
62f9875f90
|
@ -2699,7 +2699,7 @@ void Tokenizer::setVarId()
|
|||
tok = tok2->previous();
|
||||
}
|
||||
|
||||
else if (decl && Token::Match(tok2->previous(), "%type% ( !!)")) {
|
||||
else if (decl && Token::Match(tok2->previous(), "%type% ( !!)") && Token::simpleMatch(tok2->link(), ") ;")) {
|
||||
// In C++ , a variable can't be called operator+ or something like that.
|
||||
if (isCPP() &&
|
||||
tok2->previous()->str().size() >= 9 &&
|
||||
|
|
|
@ -724,8 +724,8 @@ private:
|
|||
void functionArgs1() {
|
||||
{
|
||||
GET_SYMBOL_DB("void f(std::vector<std::string>, const std::vector<int> & v) { }");
|
||||
TODO_ASSERT_EQUALS(1+1, 1+2, db->getVariableListSize());
|
||||
const Variable* v = db->getVariableFromVarId(2); // TODO: varId 1
|
||||
ASSERT_EQUALS(1+1, db->getVariableListSize());
|
||||
const Variable* v = db->getVariableFromVarId(1);
|
||||
ASSERT(v && v->isReference() && v->isConst() && v->isArgument());
|
||||
const Scope* f = db->findScopeByName("f");
|
||||
ASSERT(f && f->type == Scope::eFunction && f->function);
|
||||
|
|
|
@ -214,6 +214,7 @@ private:
|
|||
TEST_CASE(varid46); // struct varname
|
||||
TEST_CASE(varid47); // function parameters
|
||||
TEST_CASE(varid48); // #3785 - return (a*b)
|
||||
TEST_CASE(varid49); // #3799 - void f(std::vector<int>)
|
||||
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||
TEST_CASE(varidFunctionCall1);
|
||||
TEST_CASE(varidFunctionCall2);
|
||||
|
@ -3249,6 +3250,13 @@ private:
|
|||
tokenizeDebugListing(code, false, "test.c"));
|
||||
}
|
||||
|
||||
void varid49() { // #3799 - void f(std::vector<int>)
|
||||
const std::string code("void f(std::vector<int>)");
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: void f ( std :: vector < int > )\n",
|
||||
tokenizeDebugListing(code, false, "test.cpp"));
|
||||
}
|
||||
|
||||
void varid_cpp_keywords_in_c_code() {
|
||||
const char code[] = "void f() {\n"
|
||||
" delete d;\n"
|
||||
|
|
Loading…
Reference in New Issue