Fixed #4239 (segmentation fault of cppcheck (invalid code))
This commit is contained in:
parent
b15cb09af6
commit
074b7781b2
|
@ -1016,17 +1016,19 @@ void Tokenizer::simplifyTypedef()
|
|||
if (!func)
|
||||
continue;
|
||||
|
||||
/** @todo add support for multi-token operators */
|
||||
if (func->previous()->str() == "operator")
|
||||
func = func->previous();
|
||||
if (func->previous()) { // Ticket #4239
|
||||
/** @todo add support for multi-token operators */
|
||||
if (func->previous()->str() == "operator")
|
||||
func = func->previous();
|
||||
|
||||
// check for qualifier
|
||||
if (func->previous()->str() == "::") {
|
||||
// check for available and matching class name
|
||||
if (!spaceInfo.empty() && classLevel < spaceInfo.size() &&
|
||||
func->strAt(-2) == spaceInfo[classLevel].className) {
|
||||
memberScope = 0;
|
||||
inMemberFunc = true;
|
||||
// check for qualifier
|
||||
if (func->previous()->str() == "::") {
|
||||
// check for available and matching class name
|
||||
if (!spaceInfo.empty() && classLevel < spaceInfo.size() &&
|
||||
func->strAt(-2) == spaceInfo[classLevel].className) {
|
||||
memberScope = 0;
|
||||
inMemberFunc = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
TEST_CASE(tokenize22); // special marker $ from preprocessor
|
||||
TEST_CASE(tokenize23); // tokenize "return - __LINE__;"
|
||||
TEST_CASE(tokenize24); // #4195 (segmentation fault)
|
||||
TEST_CASE(tokenize25); // #4239 (segmentation fault)
|
||||
|
||||
// don't freak out when the syntax is wrong
|
||||
TEST_CASE(wrong_syntax1);
|
||||
|
@ -651,6 +652,11 @@ private:
|
|||
tokenizeAndStringify("enum { int f ( ) { return = } r = f ( ) ; }");
|
||||
}
|
||||
|
||||
// #4239 - segfault for "f ( struct { int typedef T x ; } ) { }"
|
||||
void tokenize25() {
|
||||
tokenizeAndStringify("f ( struct { int typedef T x ; } ) { }");
|
||||
}
|
||||
|
||||
void wrong_syntax1() {
|
||||
{
|
||||
const std::string code("TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))");
|
||||
|
|
Loading…
Reference in New Issue