Fixed #9881 ((Regression) Hang with operator() in function call)
This commit is contained in:
parent
07f6876dc8
commit
c0ef640304
|
@ -11265,8 +11265,12 @@ void Tokenizer::simplifyOverloadedOperators()
|
|||
while (Token::simpleMatch(start, ",")) {
|
||||
if (Token::simpleMatch(start->previous(), ")"))
|
||||
start = start->linkAt(-1);
|
||||
else
|
||||
break;
|
||||
if (Token::Match(start->previous(), "%name%"))
|
||||
start = start->tokAt(-2);
|
||||
else
|
||||
break;
|
||||
}
|
||||
const Token *after = tok->linkAt(1);
|
||||
while (Token::Match(after, ")|} , %name% (|{"))
|
||||
|
|
|
@ -418,6 +418,7 @@ private:
|
|||
|
||||
TEST_CASE(simplifyOverloadedOperators1);
|
||||
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
|
||||
TEST_CASE(simplifyOverloadedOperators3); // #9881 - hang
|
||||
|
||||
TEST_CASE(simplifyNullArray);
|
||||
|
||||
|
@ -6665,6 +6666,24 @@ private:
|
|||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyOverloadedOperators3() { // #9881
|
||||
const char code[] = "struct Func { double operator()(double x) const; };\n"
|
||||
"void foo(double, double);\n"
|
||||
"void test() {\n"
|
||||
" Func max;\n"
|
||||
" double y = 0;\n"
|
||||
" foo(0, max(y));\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("struct Func { double operator() ( double x ) const ; } ;\n"
|
||||
"void foo ( double , double ) ;\n"
|
||||
"void test ( ) {\n"
|
||||
"Func max ;\n"
|
||||
"double y ; y = 0 ;\n"
|
||||
"foo ( 0 , max . operator() ( y ) ) ;\n"
|
||||
"}",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyNullArray() {
|
||||
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue