Fix issue when parsing anonymous namespaces
This commit is contained in:
parent
6a09a5253e
commit
75fbc577ad
3 changed files with 25 additions and 2 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue