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] Better diagnostics for C++ comments in C90 (PR c/61854)


On Mon, 15 Sep 2014, Marek Polacek wrote:

> We must be careful to properly handle code such as "1 //**/ 2", which
> has a different meaning in C90 and GNU90 mode.  New testcases test this.

I don't think there's sufficient allowance here for other valid cases.  
It's valid to have // inside #if 0 in C90, for example, so that must not 
be diagnosed (must not have a pedwarn or error, at least, that is).  It's 
also valid to have it in a macro expansion; e.g.:

#define h(x) #x
#define s(x) h(x)
#define foo //

and then s(foo) must expand to the string "//".

Clearly, in any case, with or without the diagnostics, these cases should 
have testcases in the testsuite.  But because // is only invalid in C90 if 
it actually results in two consecutive / tokens (not just preprocessing 
tokens), as such consecutive tokens are not part of any valid C90 program, 
a more conservative approach may be needed to avoid errors for valid 
cases.

-- 
Joseph S. Myers
joseph@codesourcery.com


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