Tokenizer::setVarId: better handling of c++ casts
This commit is contained in:
parent
33f384c48e
commit
30353d4b61
|
@ -2494,7 +2494,7 @@ void Tokenizer::setVarId()
|
|||
notstart.insert("sizeof");
|
||||
notstart.insert("typedef");
|
||||
if (!isC()) {
|
||||
static const char *str[] = {"delete","friend","new","throw","using","virtual","explicit"};
|
||||
static const char *str[] = {"delete","friend","new","throw","using","virtual","explicit","const_cast","dynamic_cast","reinterpret_cast","static_cast"};
|
||||
notstart.insert(str, str+(sizeof(str)/sizeof(*str)));
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ private:
|
|||
TEST_CASE(varid_templatePtr); // #4319
|
||||
TEST_CASE(varid_templateNamespaceFuncPtr); // #4172
|
||||
TEST_CASE(varid_templateArray);
|
||||
TEST_CASE(varid_cppcast); // #6190
|
||||
TEST_CASE(varid_variadicFunc);
|
||||
TEST_CASE(varid_typename); // #4644
|
||||
TEST_CASE(varid_rvalueref);
|
||||
|
@ -1728,6 +1729,20 @@ private:
|
|||
tokenize("VertexArrayIterator<float[2]> attrPos = m_AttributePos.GetIterator<float[2]>();"));
|
||||
}
|
||||
|
||||
void varid_cppcast() {
|
||||
ASSERT_EQUALS("\n\n##file 0\n1: const_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
||||
tokenize("const_cast<int *>(code)[0] = 0;"));
|
||||
|
||||
ASSERT_EQUALS("\n\n##file 0\n1: dynamic_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
||||
tokenize("dynamic_cast<int *>(code)[0] = 0;"));
|
||||
|
||||
ASSERT_EQUALS("\n\n##file 0\n1: reinterpret_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
||||
tokenize("reinterpret_cast<int *>(code)[0] = 0;"));
|
||||
|
||||
ASSERT_EQUALS("\n\n##file 0\n1: static_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
||||
tokenize("static_cast<int *>(code)[0] = 0;"));
|
||||
}
|
||||
|
||||
void varid_variadicFunc() {
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: int foo ( . . . ) ;\n", tokenize("int foo(...);"));
|
||||
|
|
Loading…
Reference in New Issue