This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Make parser revert digraph "<:"
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> | While this diagnostic is technically more accurate, I think it's both
> | more confusing and poorer English. How's this?
> |
> | error: '<::' cannot begin a template-argument list
>
> The confusing thing about this suggestion is that the beginning of the
> template-argument list is not '<::'.
But it is '<::', in the most important place: in the source file. The
programmer wrote
T<::whatever>
and that is what s/he will see in a text editor, so the error message
is most helpful by using that sequence of symbols. It is vanishingly
unlikely that the programmer actually wrote T <: : whatever; cpplib
does give the ability to test for this, via the PREV_WHITE flag on the
: token, but I doubt it is worthwhile.
> It is like writing
>
> +++i
>
> which gets lexed as ++ + i and not + ++ i. How would you phrase the
> diagnostic for that?
"+++i" is a valid C99 unary-expression. It is semantically invalid,
because "+i" is not a modifiable lvalue, but it parses. So I would
say something like
error: invalid lvalue in increment
note: "+++" is parsed as "++ +" not "+ ++"
assuming that it is possible to detect this case at the point where
the invalid lvalue diagnostic issues.
> Yes, that is one of the items on the C++ Evolution Working Group wishlist
> we would like to address as cleanly as possible.
May I suggest that a plausible (and generally helpful, not just with
templates) first step would be
#pragma STDCXX (DIGRAPHS|TRIGRAPHS) (ON|OFF)
? This would be trivial to implement under the #pragma GCC namespace
as a demonstration.
> Also, see suggestion ES018 at
>
> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1512.html
>
> for things like
>
> vector<list<int>> vl;
What is GJ?
zw