This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Make parser revert digraph "<:"

Gabriel Dos Reis <> writes:

> "Giovanni Bajo" <> 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?)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]