Tokenizer: Replace __null with 0 (gcc constant)
This commit is contained in:
parent
c592ccd35d
commit
95e917b27f
|
@ -2071,7 +2071,8 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
// Replace NULL with 0..
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "NULL" || tok->str() == "'\\0'" || tok->str() == "'\\x0'")
|
||||
if (tok->str() == "NULL" || tok->str() == "__null" ||
|
||||
tok->str() == "'\\0'" || tok->str() == "'\\x0'")
|
||||
{
|
||||
tok->str("0");
|
||||
}
|
||||
|
|
|
@ -213,6 +213,7 @@ private:
|
|||
TEST_CASE(simplify_constants);
|
||||
TEST_CASE(simplify_constants2);
|
||||
TEST_CASE(simplify_constants3);
|
||||
TEST_CASE(simplify_null);
|
||||
|
||||
TEST_CASE(vardecl1);
|
||||
TEST_CASE(vardecl2);
|
||||
|
@ -3879,6 +3880,16 @@ private:
|
|||
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
||||
}
|
||||
|
||||
void simplify_null()
|
||||
{
|
||||
const char code[] =
|
||||
"int * p = NULL;\n"
|
||||
"int * q = __null;\n";
|
||||
const char expected[] =
|
||||
"int * p ; p = 0 ;\nint * q ; q = 0 ;";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
||||
}
|
||||
|
||||
void vardecl1()
|
||||
{
|
||||
const char code[] = "unsigned int a, b;";
|
||||
|
|
Loading…
Reference in New Issue