On Sun, 12 Dec 2021 at 05:39, Jason Merrill <ja...@redhat.com> wrote:
>
> In reading C++ diagnostics, it's often hard to find the name of the
function
> in the middle of the template header, return type, parameters, and
template
> arguments.  So let's colorize it, and maybe the template argument bindings
> while we're at it.
>
> I've somewhat arbitrarily chosen bold green for the function name, and
> non-bold magenta for the template arguments.  I'm not at all attached to
> these choices.
>
> A side-effect is that when this happens in a quote (i.e. %qD), the
> rest of the quote after the function name is no longer bold.  I think
that's
> acceptable; returning to the bold would require maintaining a colorize
stack
> instead of the on/off controls we have now.
>
> Any thoughts?

I thought I was going to love this ... and it's a nice little improvement,
but I didn't love it as much as I expected.

Is it intentional that only the last function in the instantiation stack
gets colourized? In this example the function on line 390 isn't highlighted:

/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:390:19: error: no
match for call to '(std::ranges::__cust_access::_End) (adl::Footie [])'
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:165:9:
note: candidate:
'template<class _Tp>  requires (__maybe_borrowed_range<_Tp>) &&
((is_bounded_array_v<typename std::remove_reference<_Tp>::type*>) ||
(__member_end<_Tp>) || (__adl_end<_Tp>)) constexpr auto
std::ranges::__cust_access::_End::operator()(_Tp&&) const' *
 165 |         operator()[[nodiscard]](_Tp&& __t) const
noexcept(_S_noexcept<_Tp&>())
     |         ^~~~~~~~
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:165:9:
note:   template
argument deduction/substitution failed:
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:165:9:
note: constraints
not satisfied
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h: In substitution
of 'template<class _Tp>  requires (__maybe_borrowed_range<_Tp>) &&
((is_bounded_array_v<typename std::remove_reference<_Tp>::type>) |*|
(__member_end<_Tp>) || (__adl_end<_Tp>)) constexpr auto
std::ranges::__cust_access::_End::operator()(_Tp&&) const [with _Tp =
adl::Footie (&)[]]*':
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:390:12:
  required by substitution of 'template<class _Tp>  requires
(is_bounded_array_v<typename std::remove_reference<_Tp>::type>) ||
(__member_size*<_Tp>) || (__adl_size<_Tp>) || (__sentinel_size<_Tp>)
constexpr auto std::ranges::__cust_access::_Size::operator()(_Tp&&) const
[with _Tp = adl::Footie (&)[]]*'
r.C:19:27:   required from here
/home/jwakely/gcc/12/include/c++/12.0.0/bits/ranges_base.h:165:2:
  required by the constraints of 'template<class _Tp>  requires
(__maybe_borrowed_range<_Tp>) && ((is_bounded_array_v<typename
std::remove_refe*rence<_Tp>::type>) || (__member_end<_Tp>) ||
(__adl_end<_Tp>)) constexpr auto
std::ranges::__cust_access::_End::operator()**(_Tp&&) const*'

Aside: it's a little odd that the first caret diagnostic there only
highlights the word "operator" and not the name of the function,
"operator()".

With Konsole's Solarized (dark) colour scheme the FG_GREEN colour is
actually a slightly darker grey than the surrounding text, which makes it
harder to find, but I can adjust that with GCC_COLORS.

Reply via email to