https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638

            Bug ID: 61638
           Summary: "warning: multi-line comment" unclear and has false
                    positives
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zackw at panix dot com

The warning for a // comment continued on the next line by a backslash is
"warning: multi-line comment", which doesn't make a whole lot of sense if you
don't already know that this is a possibility.  (Caret diagnostics help, but
the caret is in the wrong place: it points at the //, not the \.)

It also warns when the construct is harmless, e.g. because the next line has
another // comment on it: this naturally happens when someone feels like
drawing a tree

  //    A
  //   / \
  //  B   C

This peeves people enough to write snarky comments like this (from
https://code.monotone.ca/p/monotone/source/tree/h:net.venge.monotone/test/unit/tests/graph.cc#L260
):

  // This tests the nasty case described in the giant comment above
  // get_uncommon_ancestors:
  //
  //              9
  //              |\                  . Extraneous dots brought to you by the
  //              8 \                 . Committee to Shut Up the C Preprocessor
  //             /|  \                . (CSUCPP), and viewers like you and me.
  //            / |   |
  // (... ASCII art continues ...)

So I would like to suggest the following four improvements:

1) The warning message should be changed to "warning: backslash-newline
continues // comment onto the next line".
2) The caret should be corrected to point to the backslash, not the //.
3) The warning should be suppressed if the next line is blank or contains only
another // comment.  (It should *not* be suppressed if the next line is blank
up to a /*, because that genuinely does change the meaning of the code.
4) "warning: backslash and newline separated by space" should not be suppressed
in // comments, because see bug 8270 for a whole bunch of people being very
confused why putting a space after the backslash in their ASCII art doesn't
make it not a backslash-newline.  (It should still be suppressed in /*
comments.)

Reply via email to