diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 2d866dd9c..13ee9de8b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1811,7 +1811,7 @@ namespace { return false; } - if (Token::Match(tok1->tokAt(-1), "class|struct|union|enum")) { + if (Token::Match(tok1->tokAt(-1), "class|struct|union|enum|namespace")) { // fixme return false; } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index a959859a9..6c47905c4 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -68,6 +68,7 @@ private: TEST_CASE(simplifyUsing9381); TEST_CASE(simplifyUsing9385); TEST_CASE(simplifyUsing9388); + TEST_CASE(simplifyUsing9518); } std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) { @@ -619,6 +620,16 @@ private: ASSERT_EQUALS(exp, tok(code, false)); } + void simplifyUsing9518() { + const char code[] = "namespace a {\n" + "using a = enum {};\n" + "}"; + const char exp[] = "namespace a { " + "enum a { } ; " + "}"; + ASSERT_EQUALS(exp, tok(code, false)); + } + }; REGISTER_TEST(TestSimplifyUsing)