diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 97b267849..65b0512e0 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1388,6 +1388,11 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn) while (Token::simpleMatch(tok, ".")) tok = tok->astOperand2(); while (Token::simpleMatch(tok, "::")) { + // If there is only a op1 and not op2, then this is a global scope + if (!tok->astOperand2() && tok->astOperand1()) { + tok = tok->astOperand1(); + break; + } tok = tok->astOperand2(); if (Token::simpleMatch(tok, "<") && tok->link()) tok = tok->astOperand1(); diff --git a/test/teststl.cpp b/test/teststl.cpp index 196a393b9..24f59c045 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -4713,6 +4713,20 @@ private: "}\n", true); ASSERT_EQUALS("", errout.str()); + + check("static void f1(std::list& parameters) {\n" + " parameters.push_back(a);\n" + "}\n" + "int f2(std::list& parameters) {\n" + " f1(parameters);\n" + "}\n" + "void f3() {\n" + " std::list parameters;\n" + " int res = ::f2(parameters);\n" + " for (auto param : parameters) {}\n" + "}\n", + true); + ASSERT_EQUALS("", errout.str()); } void checkMutexes() {