template simplifier: fix function forward declaration bug for constructor with initializer list. (#1497)

This commit is contained in:
IOBYTE 2018-11-29 00:24:28 -05:00 committed by Daniel Marjamäki
parent e11afb7b0c
commit 3d024f3f6d
2 changed files with 16 additions and 1 deletions

View File

@ -1047,7 +1047,7 @@ void TemplateSimplifier::expandTemplate(
start = templateDeclarationToken->next();
end = templateDeclarationNameToken->linkAt(1)->next();
}
while (!Token::Match(end, ";|{"))
while (!Token::Match(end, ";|{|:"))
end = end->next();
std::map<const Token *, Token *> links;

View File

@ -120,6 +120,7 @@ private:
TEST_CASE(template80);
TEST_CASE(template81);
TEST_CASE(template82); // 8603
TEST_CASE(template83);
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
@ -1593,6 +1594,20 @@ private:
ASSERT_EQUALS(exp, tok(code));
}
void template83() {
const char code[] = "template<typename Task>\n"
"MultiConsumer<Task>::MultiConsumer() : sizeBuffer(0) {}\n"
"MultiReads::MultiReads() {\n"
" mc = new MultiConsumer<reads_packet>();\n"
"}";
const char exp[] = "MultiConsumer<reads_packet> :: MultiConsumer<reads_packet> ( ) ; "
"MultiReads :: MultiReads ( ) { "
"mc = new MultiConsumer<reads_packet> ( ) ; "
"} "
"MultiConsumer<reads_packet> :: MultiConsumer<reads_packet> ( ) : sizeBuffer ( 0 ) { }";
ASSERT_EQUALS(exp, tok(code));
}
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
const char code[] = "template <typename T> struct C {};\n"
"template <typename T> struct S {a};\n"