fix syntax error for VTK_LEGACY_BODY(vtkMatrix3x3::operator[], "VTK 7.0"); (#2372)

This commit is contained in:
IOBYTE 2019-11-18 00:38:53 -05:00 committed by Daniel Marjamäki
parent 2f00141c72
commit 7f6ebaa6b2
2 changed files with 28 additions and 0 deletions

View File

@ -10880,6 +10880,8 @@ void Tokenizer::simplifyOperatorName()
done = false;
} else if (Token::Match(par, ".|%op%|,")) {
// check for operator in template
if (par->str() == "," && !op.empty())
break;
if (!(Token::Match(par, "<|>") && !op.empty())) {
op += par->str();
par = par->next();

View File

@ -407,6 +407,7 @@ private:
TEST_CASE(simplifyOperatorName20);
TEST_CASE(simplifyOperatorName21);
TEST_CASE(simplifyOperatorName22);
TEST_CASE(simplifyOperatorName23);
TEST_CASE(simplifyNullArray);
@ -6521,6 +6522,31 @@ private:
tokenizeAndStringify(code));
}
void simplifyOperatorName23() {
{
const char code[] = "double *vtkMatrix3x3::operator[](const unsigned int i) {"
" VTK_LEGACY_BODY(vtkMatrix3x3::operator[], \"VTK 7.0\");"
" return &(this->Element[i][0]);"
"}";
ASSERT_EQUALS("double * vtkMatrix3x3 :: operator[] ( const unsigned int i ) { "
"VTK_LEGACY_BODY ( vtkMatrix3x3 :: operator[] , \"VTK 7.0\" ) ; "
"return & ( this . Element [ i ] [ 0 ] ) ; "
"}",
tokenizeAndStringify(code));
}
{
const char code[] = "double *vtkMatrix3x3::operator,(const unsigned int i) {"
" VTK_LEGACY_BODY(vtkMatrix3x3::operator,, \"VTK 7.0\");"
" return &(this->Element[i][0]);"
"}";
ASSERT_EQUALS("double * vtkMatrix3x3 :: operator, ( const unsigned int i ) { "
"VTK_LEGACY_BODY ( vtkMatrix3x3 :: operator, , \"VTK 7.0\" ) ; "
"return & ( this . Element [ i ] [ 0 ] ) ; "
"}",
tokenizeAndStringify(code));
}
}
void simplifyNullArray() {
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
}