Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193

This commit is contained in:
Daniel Marjamäki 2011-10-12 19:23:39 +02:00
parent cf39ece8da
commit 371871b0b7
2 changed files with 3 additions and 1 deletions

View File

@ -4854,7 +4854,8 @@ void Tokenizer::removeMacrosInGlobalScope()
if (tok->str() == "(")
{
tok = tok->link();
if (Token::Match(tok, ") %type% {") && tok->strAt(1) != "const")
if (Token::Match(tok, ") %type% {") &&
!Token::Match(tok->next(), "const|namespace|class|struct|union"))
tok->deleteNext();
}

View File

@ -5946,6 +5946,7 @@ private:
// remove some unhandled macros in the global scope.
ASSERT_EQUALS("void f ( ) { }", tokenizeAndStringify("void f() NOTHROW { }"));
ASSERT_EQUALS("struct Foo { } ;", tokenizeAndStringify("struct __declspec(dllexport) Foo {};"));
ASSERT_EQUALS("ABA ( ) namespace { }", tokenizeAndStringify("ABA() namespace { }"));
}
void multipleAssignment()