Workaround token issue in unnamed variadic template parameter

This commit is contained in:
Jonathan Müller 2017-04-12 21:28:02 +02:00
commit 133d51b630
2 changed files with 16 additions and 2 deletions

View file

@ -166,6 +166,18 @@ namespace
// now we found the proper end of the token // now we found the proper end of the token
end = get_next_location(tu, file, next, -1); end = get_next_location(tu, file, next, -1);
} }
else if ((kind == CXCursor_TemplateTypeParameter
|| kind == CXCursor_NonTypeTemplateParameter
|| kind == CXCursor_TemplateTemplateParameter)
&& token_after_is(tu, file, cur, end, "..."))
{
// variadic tokens in unnamed parameter not included
end = get_next_location(tu, file, end, 3);
DEBUG_ASSERT(token_after_is(tu, file, cur, end, ">")
|| token_after_is(tu, file, cur, end, ","),
detail::parse_error_handler{}, cur,
"unexpected token in variadic parameter workaround");
}
else if ((kind == CXCursor_TemplateTypeParameter else if ((kind == CXCursor_TemplateTypeParameter
|| kind == CXCursor_NonTypeTemplateParameter || kind == CXCursor_NonTypeTemplateParameter
|| kind == CXCursor_TemplateTemplateParameter) || kind == CXCursor_TemplateTemplateParameter)
@ -173,7 +185,8 @@ namespace
&& !token_after_is(tu, file, cur, end, ",")) && !token_after_is(tu, file, cur, end, ","))
{ {
DEBUG_ASSERT(token_after_is(tu, file, cur, get_next_location(tu, file, end, -2), ">>"), DEBUG_ASSERT(token_after_is(tu, file, cur, get_next_location(tu, file, end, -2), ">>"),
detail::assert_handler{}); detail::parse_error_handler{}, cur,
"unexpected token in maximal munch workaround");
unmunch = true; unmunch = true;
// need to shrink range anyway // need to shrink range anyway
end = get_next_location(tu, file, end, -1); end = get_next_location(tu, file, end, -1);

View file

@ -209,7 +209,7 @@ using b = void;
template <template <int> class C = ns::def> template <template <int> class C = ns::def>
using c = void; using c = void;
template <template <template <typename> class> class D = a> template <template <template <typename...> class> class D = a>
using d = void; using d = void;
)"; )";
@ -309,6 +309,7 @@ using d = void;
++no; ++no;
REQUIRE(p_p_param.name() == ""); REQUIRE(p_p_param.name() == "");
REQUIRE(p_p_param.kind() == cpp_entity_kind::template_type_parameter_t); REQUIRE(p_p_param.kind() == cpp_entity_kind::template_type_parameter_t);
REQUIRE(p_p_param.is_variadic());
} }
} }
REQUIRE(no == 2u); REQUIRE(no == 2u);