From 3d0338e9f9d594e3b0b49724517ff74c4fbbca2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 23 Jan 2016 09:48:21 +0100 Subject: [PATCH] Fixed #7212 (incorrectly adding function argument with no name) --- lib/symboldatabase.cpp | 2 +- test/testsymboldatabase.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index aa66d13cb..7ee98ca8b 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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(); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 430a348a4..ca739c5cd 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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("");