From 371871b0b7df46c6c50b0bd56e08ac823c3c9945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 12 Oct 2011 19:23:39 +0200 Subject: [PATCH] Tokenizer::removeMacrosInGlobalScope: Don't remove C/C++ keywords namespace/struct/etc. Ticket: #3193 --- lib/tokenize.cpp | 3 ++- test/testtokenize.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8be09a51e..14e20573c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 323029b4a..82b082920 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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()