This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix error level of warning about C++ style comments
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Franklin <j_fra at fastmail dot us>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 17 Jul 2018 17:07:25 +0200
- Subject: Re: [PATCH] Fix error level of warning about C++ style comments
- References: <1531839102.2603788.1443656544.2D77EFD3@webmail.messagingengine.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jul 17, 2018 at 07:51:42AM -0700, Jason Franklin wrote:
> Greetings,
>
> Below is a simple patch for fixing the error level of an additional note
> that follows a warning about using C++ style comments. The ChangeLog
> entry is below, followed by the patch.
>
> Tried to figure out how to run the tests, but not sure if it's necessary for
> something so simple... would appreciate some guidance here.
>
> Let me know if everything looks good. Thanks!
>
>
> 2018-07-17 Jason Franklin <j_fra@fastmail.us>
>
> * libcpp/lex.c: Fix error level for note following warning about
> the use of C++ style comments.
The ChangeLog entry for libcpp/ should not include libcpp/ prefix and
should include the function name, so:
* lex.c (_cpp_lex_direct): Fix ...
> diff --git a/libcpp/lex.c b/libcpp/lex.c
> index 37c365a3560..4b93691bd1e 100644
> --- a/libcpp/lex.c
> +++ b/libcpp/lex.c
> @@ -2874,7 +2874,7 @@ _cpp_lex_direct (cpp_reader *pfile)
> {
> cpp_error (pfile, CPP_DL_PEDWARN,
> "C++ style comments are not allowed in ISO C90");
> - cpp_error (pfile, CPP_DL_PEDWARN,
> + cpp_error (pfile, CPP_DL_NOTE,
> "(this will be reported only once per input file)");
This has the undesirable effect that for say:
// foo
int i;
you get with this patch:
gcc -S -pedantic test.c -std=gnu89 -w
test.c:1:1: note: (this will be reported only once per input file)
// foo
^
while before that you'd get no diagnostics at all.
So, instead it should do:
if (cpp_error (pfile, CPP_DL_PEDWARN,
"C++ style comments are not allowed in ISO C90"))
cpp_error (pfile, CPP_DL_NOTE,
"(this will be reported only once per input file)");
which makes sure the note is emitted only if the warning/error before it is
emitted.
> buffer->warned_cplusplus_comments = 1;
> }
> @@ -2885,7 +2885,7 @@ _cpp_lex_direct (cpp_reader *pfile)
> {
> cpp_error (pfile, CPP_DL_WARNING,
> "C++ style comments are incompatible with C90");
> - cpp_error (pfile, CPP_DL_WARNING,
> + cpp_error (pfile, CPP_DL_NOTE,
> "(this will be reported only once per input file)");
> buffer->warned_cplusplus_comments = 1;
> }
Likewise. Furthermore, there is
cpp_error (pfile, CPP_DL_ERROR,
"C++ style comments are not allowed in ISO C90");
cpp_error (pfile, CPP_DL_ERROR,
"(this will be reported only once per input "
"file)");
a few lines below, this third spot needs a similar change too.
Jakub