This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] Make parser revert digraph "<:"
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: "Giovanni Bajo" <giovannibajo at libero dot it>, "Mark Mitchell" <mark at codesourcery dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 25 Jan 2004 20:54:06 -0800
- Subject: Re: [C++ PATCH] Make parser revert digraph "<:"
- References: <0b6301c3e3ae$a38b35d0$62b92997@bagio><email@example.com>
Gabriel Dos Reis <firstname.lastname@example.org> writes:
> "Giovanni Bajo" <email@example.com> writes:
> | Hello Mark,
> | this patch makes the parser aware that "<:" is a digraph for "[". In other
> | words, if the parser sees "A[:0>", where A is a template, it will parse it as
> | "A< ::0>", and will emit the following diagnostic:
> | error: template parameter list is invalid because `<:' is a digraph for `['
> | note: use `< ::' to avoid forming the digraph
> I would rather see the diagnostic as
> error: check the spelling of the template-argument list; '<:' is a
> digraph (another spelling for '['). Insert a whitespace between
> '<' and '::'.
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
note: '<:' is an alternate spelling for '[', insert whitespace
between '<' and '::'
(I moved all of the verbose explanation to the note: because I want a
-fno-explanations mode in which all inform() calls do nothing, for
people who have seen it all before and don't need to hear it again.)
(I wonder if anyone will request a do-what-I-mean mode, in which this
and other places where template syntax clashes with greedy tokenization
are all parsed the way the programmer 'obviously' meant?)