Fixed #7212 (incorrectly adding function argument with no name)

This commit is contained in:
Daniel Marjamäki 2016-01-23 09:48:21 +01:00
parent 2627aada07
commit 3d0338e9f9
2 changed files with 15 additions and 1 deletions

View File

@ -2556,7 +2556,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
if (hasBody())
symbolDatabase->debugMessage(nameTok, "Function::addArguments found argument \'" + nameTok->str() + "\' with varid 0.");
} else
endTok = startTok;
endTok = typeTok;
} else
endTok = tok->previous();
}

View File

@ -171,6 +171,7 @@ private:
TEST_CASE(checkTypeStartEndToken1);
TEST_CASE(checkTypeStartEndToken2); // handling for unknown macro: 'void f() MACRO {..'
TEST_CASE(checkTypeStartEndToken3); // no variable name: void f(const char){}
TEST_CASE(functionArgs1);
TEST_CASE(functionArgs2);
@ -1357,6 +1358,19 @@ private:
ASSERT_EQUALS("DiagnosticsEngine", db->getVariableFromVarId(1)->typeStartToken()->str());
}
void checkTypeStartEndToken3() {
GET_SYMBOL_DB("void f(const char) {}");
ASSERT(db && db->functionScopes.size()==1U);
if (db && db->functionScopes.size()==1U) {
const Function * const f = db->functionScopes.front()->function;
ASSERT_EQUALS(1U, f->argCount());
const Variable * const arg1 = f->getArgumentVar(0);
ASSERT_EQUALS("char", arg1->typeStartToken()->str());
ASSERT_EQUALS("char", arg1->typeEndToken()->str());
}
}
void check(const char code[], bool debug = true) {
// Clear the error log
errout.str("");