diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3915fb30a..5ad5497c7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1724,7 +1724,7 @@ void Tokenizer::simplifyNamespaces() { for (Token *token = _tokens; token; token = token->next()) { - while (token && token->str() == "namespace" && + while (token && token->str() == "namespace" && token->varId() == 0 && (!token->previous() || token->previous()->str() != "using")) { // Token is namespace and there is no "using" before it. diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 1ada1aab6..05909251b 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1576,6 +1576,14 @@ private: ASSERT_EQUALS(expected, sizeof_(code)); } + + { + const char code[] = "void f(int namespace) { }"; + + const std::string expected("void f ( int namespace ) { }"); + + ASSERT_EQUALS(expected, sizeof_(code)); + } }