Fix issue when parsing anonymous namespaces

This commit is contained in:
Jonathan Müller 2017-04-10 21:02:23 +02:00
commit 75fbc577ad
3 changed files with 25 additions and 2 deletions

View file

@ -29,6 +29,10 @@ namespace c
/// }
namespace d {}
}
/// namespace {
/// }
namespace {}
)";
auto file = parse({}, "cpp_namespace.cpp", code);
@ -36,29 +40,39 @@ namespace c
auto no_children = count_children(ns);
if (ns.name() == "a")
{
REQUIRE(!ns.is_anonymous());
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 0u);
}
else if (ns.name() == "b")
{
REQUIRE(!ns.is_anonymous());
REQUIRE(ns.is_inline());
REQUIRE(no_children == 0u);
}
else if (ns.name() == "c")
{
REQUIRE(!ns.is_anonymous());
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 1u);
}
else if (ns.name() == "d")
{
REQUIRE(!ns.is_anonymous());
check_parent(ns, "c", "c::d");
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 0u);
}
else if (ns.name() == "")
{
REQUIRE(ns.is_anonymous());
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 0u);
}
else
REQUIRE(false);
});
REQUIRE(count == 4u);
REQUIRE(count == 5u);
}
TEST_CASE("cpp_namespace_alias")