template simplifier: fix crash on windows (#1639)
* template simplifier: fix crash on windows Use right token when searching for template type alias to delete. * template simplifier: fix a cppcheck warning
This commit is contained in:
parent
8925299947
commit
d08aa666f6
|
@ -1036,9 +1036,9 @@ void TemplateSimplifier::simplifyTemplateAliases()
|
|||
}
|
||||
|
||||
// find declaration
|
||||
const std::list<TokenAndName>::iterator it2 = std::find_if(mTemplateDeclarations.begin(),
|
||||
const std::list<TokenAndName>::iterator it3 = std::find_if(mTemplateDeclarations.begin(),
|
||||
mTemplateDeclarations.end(),
|
||||
FindToken(startToken ? startToken : mTokenList.front()));
|
||||
FindToken(startToken ? startToken->next() : mTokenList.front()));
|
||||
|
||||
if (startToken)
|
||||
eraseTokens(startToken, endToken);
|
||||
|
@ -1048,8 +1048,8 @@ void TemplateSimplifier::simplifyTemplateAliases()
|
|||
}
|
||||
|
||||
// remove declaration
|
||||
if (it2 != mTemplateDeclarations.end())
|
||||
mTemplateDeclarations.erase(it2);
|
||||
if (it3 != mTemplateDeclarations.end())
|
||||
mTemplateDeclarations.erase(it3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1282,7 +1282,7 @@ private:
|
|||
tok(code); // don't crash
|
||||
}
|
||||
|
||||
void template65() { // #8321
|
||||
void template65() { // #8321 (crash)
|
||||
const char code[] = "namespace bpp\n"
|
||||
"{\n"
|
||||
"template<class N, class E, class DAGraphImpl>\n"
|
||||
|
@ -1298,7 +1298,18 @@ private:
|
|||
" AssociationDAGlobalGraphObserver<string,unsigned int> grObs;\n"
|
||||
" return 1;\n"
|
||||
"}";
|
||||
tok(code); // don't crash
|
||||
const char exp [] = "namespace bpp "
|
||||
"{ "
|
||||
"class AssociationDAGraphImplObserver<string,unsignedint,DAGlobalGraph> ; "
|
||||
"} "
|
||||
"using namespace bpp ; "
|
||||
"int main ( ) { "
|
||||
"bpp :: AssociationDAGraphImplObserver<string,unsignedint,DAGlobalGraph> grObs ; "
|
||||
"return 1 ; "
|
||||
"} class bpp :: AssociationDAGraphImplObserver<string,unsignedint,DAGlobalGraph> : "
|
||||
"public AssociationGraphImplObserver < std :: string , int , DAGlobalGraph > "
|
||||
"{ } ;";
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template66() { // #8725
|
||||
|
|
Loading…
Reference in New Issue