Fix #9388 ("debug: Executable scope 'x' with unknown function." with alias used in initialization list) (#2239)

This commit is contained in:
IOBYTE 2019-10-05 03:34:37 -04:00 committed by amai2012
parent bfbfeefbb3
commit 46f3f58e5f
2 changed files with 19 additions and 1 deletions

View File

@ -2008,7 +2008,7 @@ bool Tokenizer::simplifyUsing()
}
// check for member function
if (Token::Match(tok1->tokAt(-2), ":: %name% (") && isFunctionHead(tok1, "{")) {
if (Token::Match(tok1->tokAt(-2), ":: %name% (") && isFunctionHead(tok1, "{|:")) {
std::string qualification;
const Token *qualTok = tok1->tokAt(-3);
while (Token::Match(qualTok, "%type% ::")) {

View File

@ -67,6 +67,7 @@ private:
TEST_CASE(simplifyUsing9191);
TEST_CASE(simplifyUsing9381);
TEST_CASE(simplifyUsing9385);
TEST_CASE(simplifyUsing9388);
}
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) {
@ -585,6 +586,23 @@ private:
}
}
void simplifyUsing9388() {
const char code[] = "class A {\n"
"public:\n"
" using Type = int;\n"
" A(Type&);\n"
" Type& t_;\n"
"};\n"
"A::A(Type& t) : t_(t) { }";
const char exp[] = "class A { "
"public: "
"A ( int & ) ; "
"int & t_ ; "
"} ; "
"A :: A ( int & t ) : t_ ( t ) { }";
ASSERT_EQUALS(exp, tok(code, false));
}
};
REGISTER_TEST(TestSimplifyUsing)