* Partial fix for #11378 (iscpp11init) * Improve fix * Add fix
This commit is contained in:
parent
665e4230f2
commit
428f5016d4
|
@ -8889,7 +8889,7 @@ void Tokenizer::simplifyNamespaceStd()
|
||||||
if (Token::Match(tok, "enum class|struct| %name%| :|{")) { // Don't replace within enum definitions
|
if (Token::Match(tok, "enum class|struct| %name%| :|{")) { // Don't replace within enum definitions
|
||||||
skipEnumBody(&tok);
|
skipEnumBody(&tok);
|
||||||
}
|
}
|
||||||
if (!Token::Match(tok->previous(), ".|::")) {
|
if (!Token::Match(tok->previous(), ".|::|namespace")) {
|
||||||
if (Token::Match(tok, "%name% (")) {
|
if (Token::Match(tok, "%name% (")) {
|
||||||
if (isFunctionHead(tok->next(), "{"))
|
if (isFunctionHead(tok->next(), "{"))
|
||||||
userFunctions.insert(tok->str());
|
userFunctions.insert(tok->str());
|
||||||
|
|
|
@ -691,7 +691,7 @@ static bool iscpp11init_impl(const Token * const tok)
|
||||||
if (!Token::simpleMatch(endtok, "} ;"))
|
if (!Token::simpleMatch(endtok, "} ;"))
|
||||||
return true;
|
return true;
|
||||||
const Token *prev = nameToken;
|
const Token *prev = nameToken;
|
||||||
while (Token::Match(prev, "%name%|::|:|<|>|,")) {
|
while (Token::Match(prev, "%name%|::|:|<|>|,|%num%")) {
|
||||||
if (Token::Match(prev, "class|struct|union|enum"))
|
if (Token::Match(prev, "class|struct|union|enum"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -7506,6 +7506,32 @@ private:
|
||||||
testIsCpp11init("enum { e = decltype(s)::i };",
|
testIsCpp11init("enum { e = decltype(s)::i };",
|
||||||
"{ e",
|
"{ e",
|
||||||
TokenImpl::Cpp11init::NOINIT);
|
TokenImpl::Cpp11init::NOINIT);
|
||||||
|
|
||||||
|
testIsCpp11init("template <typename T>\n" // #11378
|
||||||
|
"class D<M<T, 1>> : public B<M<T, 1>, T> {\n"
|
||||||
|
"public:\n"
|
||||||
|
" D(int x) : B<M<T, 1>, T>(x) {}\n"
|
||||||
|
"};\n",
|
||||||
|
"{ public:",
|
||||||
|
TokenImpl::Cpp11init::NOINIT);
|
||||||
|
|
||||||
|
testIsCpp11init("template <typename T>\n"
|
||||||
|
"class D<M<T, 1>> : B<M<T, 1>, T> {\n"
|
||||||
|
"public:\n"
|
||||||
|
" D(int x) : B<M<T, 1>, 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
|
#undef testIsCpp11init
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue