Fix crash in iscpp11init_impl() (#4743)
This commit is contained in:
parent
bea6aec2b2
commit
ca0c13e27d
|
@ -677,7 +677,7 @@ static bool iscpp11init_impl(const Token * const tok)
|
||||||
return false; // trailing return type. The only function body that can contain no semicolon is a void function.
|
return false; // trailing return type. The only function body that can contain no semicolon is a void function.
|
||||||
if (Token::simpleMatch(nameToken->previous(), "namespace") || Token::simpleMatch(nameToken, "namespace") /*anonymous namespace*/)
|
if (Token::simpleMatch(nameToken->previous(), "namespace") || Token::simpleMatch(nameToken, "namespace") /*anonymous namespace*/)
|
||||||
return false;
|
return false;
|
||||||
if (endtok != nullptr && !Token::Match(nameToken, "return|:")) {
|
if (precedes(nameToken->next(), endtok) && !Token::Match(nameToken, "return|:")) {
|
||||||
// If there is semicolon between {..} this is not a initlist
|
// If there is semicolon between {..} this is not a initlist
|
||||||
for (const Token *tok2 = nameToken->next(); tok2 != endtok; tok2 = tok2->next()) {
|
for (const Token *tok2 = nameToken->next(); tok2 != endtok; tok2 = tok2->next()) {
|
||||||
if (tok2->str() == ";")
|
if (tok2->str() == ";")
|
||||||
|
|
|
@ -7654,6 +7654,9 @@ private:
|
||||||
"};\n",
|
"};\n",
|
||||||
"{ } }",
|
"{ } }",
|
||||||
TokenImpl::Cpp11init::NOINIT);
|
TokenImpl::Cpp11init::NOINIT);
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(tokenizeAndStringify("template<typename U> struct X {};\n" // don't crash
|
||||||
|
"template<typename T> auto f(T t) -> X<decltype(t + 1)> {}\n"));
|
||||||
#undef testIsCpp11init
|
#undef testIsCpp11init
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue