diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e315540ec..055fb7910 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8889,7 +8889,7 @@ void Tokenizer::simplifyNamespaceStd() if (Token::Match(tok, "enum class|struct| %name%| :|{")) { // Don't replace within enum definitions skipEnumBody(&tok); } - if (!Token::Match(tok->previous(), ".|::")) { + if (!Token::Match(tok->previous(), ".|::|namespace")) { if (Token::Match(tok, "%name% (")) { if (isFunctionHead(tok->next(), "{")) userFunctions.insert(tok->str()); diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a03ca9720..9dc8fc70e 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -691,7 +691,7 @@ static bool iscpp11init_impl(const Token * const tok) if (!Token::simpleMatch(endtok, "} ;")) return true; const Token *prev = nameToken; - while (Token::Match(prev, "%name%|::|:|<|>|,")) { + while (Token::Match(prev, "%name%|::|:|<|>|,|%num%")) { if (Token::Match(prev, "class|struct|union|enum")) return false; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1e92bc8b9..1cf64dc31 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7506,6 +7506,32 @@ private: testIsCpp11init("enum { e = decltype(s)::i };", "{ e", TokenImpl::Cpp11init::NOINIT); + + testIsCpp11init("template \n" // #11378 + "class D> : public B, T> {\n" + "public:\n" + " D(int x) : B, T>(x) {}\n" + "};\n", + "{ public:", + TokenImpl::Cpp11init::NOINIT); + + testIsCpp11init("template \n" + "class D> : B, T> {\n" + "public:\n" + " D(int x) : B, T>(x) {}\n" + "};\n", + "{ public:", + TokenImpl::Cpp11init::NOINIT); + + testIsCpp11init("using namespace std;\n" + "namespace internal {\n" + " struct S { S(); };\n" + "}\n" + "namespace internal {\n" + " S::S() {}\n" + "}\n", + "{ } }", + TokenImpl::Cpp11init::NOINIT); #undef testIsCpp11init } };