#5780 Crash on template code below Tokenizer::setVarId(). Fix several crashes with same location.
This commit is contained in:
parent
cd75b2d83d
commit
e02741c82c
|
@ -2516,7 +2516,7 @@ void Tokenizer::setVarId()
|
||||||
}
|
}
|
||||||
} else if (tok->str() == "}") {
|
} else if (tok->str() == "}") {
|
||||||
// parse anonymous unions as part of the current scope
|
// parse anonymous unions as part of the current scope
|
||||||
if (!(Token::simpleMatch(tok, "} ;") && Token::simpleMatch(tok->link()->previous(), "union {"))) {
|
if (!(Token::simpleMatch(tok, "} ;") && tok->link() && Token::simpleMatch(tok->link()->previous(), "union {"))) {
|
||||||
// Set variable ids in class declaration..
|
// Set variable ids in class declaration..
|
||||||
if (!isC() && !executableScope.top() && tok->link()) {
|
if (!isC() && !executableScope.top() && tok->link()) {
|
||||||
setVarIdClassDeclaration(tok->link(),
|
setVarIdClassDeclaration(tok->link(),
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
TEST_CASE(tokenize30); // #5356 (segmentation fault upon invalid code)
|
TEST_CASE(tokenize30); // #5356 (segmentation fault upon invalid code)
|
||||||
TEST_CASE(tokenize31); // #3503 (Wrong handling of member function taking function pointer as argument)
|
TEST_CASE(tokenize31); // #3503 (Wrong handling of member function taking function pointer as argument)
|
||||||
TEST_CASE(tokenize32); // #5884 (fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp:852:46)
|
TEST_CASE(tokenize32); // #5884 (fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp:852:46)
|
||||||
|
TEST_CASE(tokenize33); // #5780 Various crashes on valid template code
|
||||||
|
|
||||||
// don't freak out when the syntax is wrong
|
// don't freak out when the syntax is wrong
|
||||||
TEST_CASE(wrong_syntax1);
|
TEST_CASE(wrong_syntax1);
|
||||||
|
@ -905,6 +906,15 @@ private:
|
||||||
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ##5780 Various crashes on valid template code in Tokenizer::setVarId()
|
||||||
|
void tokenize33() {
|
||||||
|
const char * code = "template<typename T, typename A = Alloc<T>> struct vector {};\n"
|
||||||
|
"void z() {\n"
|
||||||
|
" vector<int> VI;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
|
||||||
void wrong_syntax1() {
|
void wrong_syntax1() {
|
||||||
{
|
{
|
||||||
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
|
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
|
||||||
|
|
Loading…
Reference in New Issue