parent
26c0945309
commit
bd7551411a
|
@ -1666,7 +1666,7 @@ void TemplateSimplifier::expandTemplate(
|
|||
while (itype < typeParametersInDeclaration.size() && typeParametersInDeclaration[itype]->str() != start->str())
|
||||
++itype;
|
||||
|
||||
if (itype < typeParametersInDeclaration.size() &&
|
||||
if (itype < typeParametersInDeclaration.size() && itype < mTypesUsedInTemplateInstantiation.size() &&
|
||||
(!isVariable || !Token::Match(typeParametersInDeclaration[itype]->previous(), "<|, %type% >|,"))) {
|
||||
typeindentlevel = 0;
|
||||
std::stack<Token *> brackets1; // holds "(" and "{" tokens
|
||||
|
@ -1919,7 +1919,7 @@ void TemplateSimplifier::expandTemplate(
|
|||
++itype;
|
||||
|
||||
// replace type with given type..
|
||||
if (itype < typeParametersInDeclaration.size()) {
|
||||
if (itype < typeParametersInDeclaration.size() && itype < mTypesUsedInTemplateInstantiation.size()) {
|
||||
unsigned int typeindentlevel = 0;
|
||||
std::stack<Token *> brackets1; // holds "(" and "{" tokens
|
||||
for (const Token *typetok = mTypesUsedInTemplateInstantiation[itype].token();
|
||||
|
@ -2024,7 +2024,7 @@ void TemplateSimplifier::expandTemplate(
|
|||
++itype;
|
||||
|
||||
// replace type with given type..
|
||||
if (itype < typeParametersInDeclaration.size()) {
|
||||
if (itype < typeParametersInDeclaration.size() && itype < mTypesUsedInTemplateInstantiation.size()) {
|
||||
unsigned int typeindentlevel = 0;
|
||||
std::stack<Token *> brackets1; // holds "(" and "{" tokens
|
||||
Token * const beforeTypeToken = mTokenList.back();
|
||||
|
|
|
@ -213,6 +213,7 @@ private:
|
|||
TEST_CASE(template169);
|
||||
TEST_CASE(template170); // crash
|
||||
TEST_CASE(template171); // crash
|
||||
TEST_CASE(template172); // #10258 crash
|
||||
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)
|
||||
|
@ -4402,6 +4403,16 @@ private:
|
|||
TODO_ASSERT_EQUALS(exp, act, tok(code));
|
||||
}
|
||||
|
||||
void template172() { // #10258 crash
|
||||
const char code[] = "template<typename T, typename... Args>\n"
|
||||
"void bar(T t, Args&&... args) { }\n"
|
||||
"void foo() { bar<int>(0, 1); }";
|
||||
const char exp[] = "void bar<int> ( int t , Args && ... args ) ; "
|
||||
"void foo ( ) { bar<int> ( 0 , 1 ) ; } "
|
||||
"void bar<int> ( int t , Args && ... args ) { }";
|
||||
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"
|
||||
|
|
Loading…
Reference in New Issue