diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 946063404..ba4125bed 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3629,16 +3629,14 @@ void Tokenizer::simplifyEmptyNamespaces() continue; if (tok->strAt(3) == "}") { tok->deleteNext(3); // remove '%var% { }' - if (tok->next()) { // '%empty% namespace %anytoken%'? - if (!tok->previous()) { - tok->deleteThis(); // remove 'namespace' - goback = true; - } else { // '%any% namespace %any%' - tok = tok->previous(); // goto previous token - tok->deleteNext(); // remove next token: 'namespace' - } - } else // '%empty% namespace %empty%'? - tok->str(";"); // change 'namespace' to ';' + if (!tok->previous()) { + // remove 'namespace' or replace it with ';' if isolated + tok->deleteThis(); + goback = true; + } else { // '%any% namespace %any%' + tok = tok->previous(); // goto previous token + tok->deleteNext(); // remove next token: 'namespace' + } } else { tok = tok->tokAt(2); }