This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Better diagnostics for C++ comments in C90 (PR c/61854)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 15 Sep 2014 17:49:25 +0000
- Subject: Re: [C PATCH] Better diagnostics for C++ comments in C90 (PR c/61854)
- Authentication-results: sourceware.org; auth=none
- References: <20140915171617 dot GG23226 at redhat dot com>
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