diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 106b78e30..caea334e5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9469,7 +9469,7 @@ void Tokenizer::simplifyNamespaceStd() skipEnumBody(&tok); } if (!Token::Match(tok->previous(), ".|::")) { - if (Token::Match(tok, "%name% (") && !Token::Match(tok->linkAt(1)->next(), "%name%|{") && stdFunctions.find(tok->str()) != stdFunctions.end()) + if (Token::Match(tok, "%name% (") && !isFunctionHead(tok->next(),"{") && stdFunctions.find(tok->str()) != stdFunctions.end()) insert = true; else if (Token::Match(tok, "%name% <") && stdTemplates.find(tok->str()) != stdTemplates.end()) insert = true; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 213c1e355..0442be5f4 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5612,6 +5612,8 @@ private: } void simplifyNamespaceStd() { + const char *code; + static const char code1[] = "map m;"; // namespace std is not used ASSERT_EQUALS("map < foo , bar > m ;", tokenizeAndStringify(code1, false)); @@ -5627,6 +5629,10 @@ private: "void foo() {swap(a, b); }"; ASSERT_EQUALS("void foo ( ) { std :: swap ( a , b ) ; }", tokenizeAndStringify(code4, false)); + code = "using namespace std;\n" + "void search() {}"; + ASSERT_EQUALS("void search ( ) { }", tokenizeAndStringify(code, false)); + static const char code5[] = "using namespace std;\n" "void foo() {map(a, b); }"; // That's obviously not std::map<> ASSERT_EQUALS("void foo ( ) { map ( a , b ) ; }", tokenizeAndStringify(code5, false));