parent
fbcb0d55d4
commit
a1c275436f
|
@ -573,7 +573,6 @@ void TemplateSimplifier::getTemplateInstantiations()
|
||||||
mTemplateInstantiations.emplace_back(tok2->next(), getScopeName(scopeList), tok2->strAt(1), tok2->tokAt(1));
|
mTemplateInstantiations.emplace_back(tok2->next(), getScopeName(scopeList), tok2->strAt(1), tok2->tokAt(1));
|
||||||
} else if (Token::Match(tok2->next(), "class|struct"))
|
} else if (Token::Match(tok2->next(), "class|struct"))
|
||||||
const_cast<Token *>(tok2)->deleteNext();
|
const_cast<Token *>(tok2)->deleteNext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add outer template..
|
// Add outer template..
|
||||||
|
@ -1026,7 +1025,7 @@ void TemplateSimplifier::expandTemplate(
|
||||||
} else if (copy && isFunction) {
|
} else if (copy && isFunction) {
|
||||||
// check if this is an explicit instantiation
|
// check if this is an explicit instantiation
|
||||||
Token * temp = templateInstantiation.token;
|
Token * temp = templateInstantiation.token;
|
||||||
while (temp && !Token::Match(temp->previous(), "}|;"))
|
while (temp && !Token::Match(temp->previous(), "}|;|extern"))
|
||||||
temp = temp->previous();
|
temp = temp->previous();
|
||||||
if (Token::Match(temp, "template !!<")) {
|
if (Token::Match(temp, "template !!<")) {
|
||||||
// just delete "template"
|
// just delete "template"
|
||||||
|
|
|
@ -122,6 +122,7 @@ private:
|
||||||
TEST_CASE(template82); // 8603
|
TEST_CASE(template82); // 8603
|
||||||
TEST_CASE(template83);
|
TEST_CASE(template83);
|
||||||
TEST_CASE(template84); // #8880
|
TEST_CASE(template84); // #8880
|
||||||
|
TEST_CASE(template85); // #8902 crash
|
||||||
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
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_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)
|
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
|
||||||
|
@ -1621,6 +1622,21 @@ private:
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void template85() { // #8902 - crash
|
||||||
|
const char code[] = "template<typename T>\n"
|
||||||
|
"struct C\n"
|
||||||
|
"{\n"
|
||||||
|
" template<typename U, typename std::enable_if<(!std::is_fundamental<U>::value)>::type* = nullptr>\n"
|
||||||
|
" void foo();\n"
|
||||||
|
"};\n"
|
||||||
|
"extern template void C<int>::foo<int, nullptr>();\n"
|
||||||
|
"template<typename T>\n"
|
||||||
|
"template<typename U, typename std::enable_if<(!std::is_fundamental<U>::value)>::type>\n"
|
||||||
|
"void C<T>::foo() {}";
|
||||||
|
// @todo the output is very wrong but we are only worried about the crash for now
|
||||||
|
tok(code);
|
||||||
|
}
|
||||||
|
|
||||||
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||||
const char code[] = "template <typename T> struct C {};\n"
|
const char code[] = "template <typename T> struct C {};\n"
|
||||||
"template <typename T> struct S {a};\n"
|
"template <typename T> struct S {a};\n"
|
||||||
|
|
Loading…
Reference in New Issue