Fixed #983 (Tokenizer::simplifyTypedef() incorrectly substitute type inside namespace)
http://sourceforge.net/apps/trac/cppcheck/ticket/983
This commit is contained in:
parent
a5e4f957fa
commit
5369965e55
|
@ -351,7 +351,7 @@ void Tokenizer::simplifyTypedef()
|
|||
int classLevel = 0;
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "class %any%"))
|
||||
if (Token::Match(tok, "class|namespace %any%"))
|
||||
{
|
||||
className = tok->next()->str();
|
||||
classLevel = 0;
|
||||
|
|
|
@ -134,6 +134,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef3)
|
||||
TEST_CASE(simplifyTypedef4)
|
||||
TEST_CASE(simplifyTypedef5)
|
||||
TEST_CASE(simplifyTypedef6)
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition);
|
||||
|
||||
|
@ -2079,6 +2080,24 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void simplifyTypedef6()
|
||||
{
|
||||
// ticket #983
|
||||
const char code[] =
|
||||
"namespace VL {\n"
|
||||
" typedef float float_t ;\n"
|
||||
" inline VL::float_t fast_atan2(VL::float_t y, VL::float_t x){}\n"
|
||||
"}\n";
|
||||
|
||||
const char expected[] =
|
||||
"namespace VL { "
|
||||
"typedef float float_t ; "
|
||||
"inline float fast_atan2 ( float y , float x ) { } "
|
||||
"}";
|
||||
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void reverseArraySyntax()
|
||||
{
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
|
|
Loading…
Reference in New Issue