This is the mail archive of the gcc-patches@gcc.gnu.org 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 wrote:

>> If people think it's *really* necessary, I can try propagating the
>> DIGRAPH flag from cpplib up to the C++ parser.

> Zack sais that the information is already present.  Are you saying
> that it is not propagated?

Yes. It is present at the cpplib level. But c_lex ignores it, so the C++ parser
can't see it.

>> It looks to me that
>> the less intrusive change  would be modifying c_lex so that it
>> stores this information in the value tree for the token (maybe
>> making it a integer_zero_node, instead of null_tree, when
>> the token came from a digraph?).

This is how I was proposing to modify c_lex so that it propagates the
information to those who care.

> This whole business of giving meaningful diagnostic is when people
> write "nonsensical" programs.  Each individual can bet on things that
> will never happen; in practice, I rather not turn the coding of the
> compiler into a lotery (yes, I know there few places like that).

My point is that we're doing a guess here, and a rather safe one, because it's
strictly context-based, and in places where any other use is not only slighlty
wrong or inexact, it's just *totally* ill-formed. But no matter how you put it,
it's still a guess, we're trying to outsmart the user. Even if I add the check
for the digraph, we might end up doing the substitution even if it was not
supposed by the user. Maybe he *did* want to use the digraph in that context
(for some insane reason). The point I am trying to make is that the number of
false positives we can detect with this code is not going to be affected that
much from checking whether there was a digraph in the real code or not.

Giovanni Bajo



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