Fix 9518 (Syntax error on valid C++) (#2424)

This commit is contained in:
IOBYTE 2019-12-05 14:51:36 -05:00 committed by Daniel Marjamäki
parent 7da68bff7b
commit 5979eec2c0
2 changed files with 12 additions and 1 deletions

View File

@ -1811,7 +1811,7 @@ namespace {
return false; return false;
} }
if (Token::Match(tok1->tokAt(-1), "class|struct|union|enum")) { if (Token::Match(tok1->tokAt(-1), "class|struct|union|enum|namespace")) {
// fixme // fixme
return false; return false;
} }

View File

@ -68,6 +68,7 @@ private:
TEST_CASE(simplifyUsing9381); TEST_CASE(simplifyUsing9381);
TEST_CASE(simplifyUsing9385); TEST_CASE(simplifyUsing9385);
TEST_CASE(simplifyUsing9388); TEST_CASE(simplifyUsing9388);
TEST_CASE(simplifyUsing9518);
} }
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) { 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)); 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) REGISTER_TEST(TestSimplifyUsing)