Jakub,

Thanks so much for the review!  Below is an updated ChangeLog entry and
patch.


2018-07-17  Jason Franklin  <j_...@fastmail.us>

        * lex.c (_cpp_lex_direct): Fix error level for note following
        warning about the use of C++ style comments.


>From 1380d73031d76be76019e67f203cb7d98fb5ee60 Mon Sep 17 00:00:00 2001
From: Jason Franklin <j_...@fastmail.us>
Date: Tue, 17 Jul 2018 11:36:39 -0400
Subject: [PATCH] Fix error level of warning about C++ comments

---
 libcpp/lex.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/libcpp/lex.c b/libcpp/lex.c
index 37c365a3560..1bf89b8da7a 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -2872,10 +2872,10 @@ _cpp_lex_direct (cpp_reader *pfile)
                   && CPP_PEDANTIC (pfile)
                   && ! buffer->warned_cplusplus_comments)
            {
-             cpp_error (pfile, CPP_DL_PEDWARN,
-                        "C++ style comments are not allowed in ISO C90");
-             cpp_error (pfile, CPP_DL_PEDWARN,
-                        "(this will be reported only once per input file)");
+             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)");
              buffer->warned_cplusplus_comments = 1;
            }
          /* Or if specifically desired via -Wc90-c99-compat.  */
@@ -2883,10 +2883,10 @@ _cpp_lex_direct (cpp_reader *pfile)
                   && ! CPP_OPTION (pfile, cplusplus)
                   && ! buffer->warned_cplusplus_comments)
            {
-             cpp_error (pfile, CPP_DL_WARNING,
-                        "C++ style comments are incompatible with C90");
-             cpp_error (pfile, CPP_DL_WARNING,
-                        "(this will be reported only once per input file)");
+             if (cpp_error (pfile, CPP_DL_WARNING,
+                        "C++ style comments are incompatible with C90"))
+                cpp_error (pfile, CPP_DL_NOTE,
+                           "(this will be reported only once per input file)");
              buffer->warned_cplusplus_comments = 1;
            }
          /* In C89/C94, C++ style comments are forbidden.  */
@@ -2906,11 +2906,11 @@ _cpp_lex_direct (cpp_reader *pfile)
                }
              else if (! buffer->warned_cplusplus_comments)
                {
-                 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)");
+                 if (cpp_error (pfile, CPP_DL_ERROR,
+                            "C++ style comments are not allowed in ISO C90"))
+                    cpp_error (pfile, CPP_DL_NOTE,
+                               "(this will be reported only once per input "
+                               "file)");
                  buffer->warned_cplusplus_comments = 1;
                }
            }
-- 
2.17.1

Reply via email to