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_...@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