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

            Bug ID: 80529
           Summary: Split "C++ style comments are not allowed in ISO C90"
                    pedwarn into its own warning flag
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egall at gwmail dot gwu.edu
  Target Milestone: ---

Given the following source:
$ cat gcctestcase01.c
// bad comment
int foo;

GCC errors on it with -std=c89 and -ansi, and warns on it with -std=gnu89
-pedantic, for example:

$ /usr/local/bin/gcc -std=gnu89 -pedantic -c gcctestcase01.c
gcctestcase01.c:1:1: warning: C++ style comments are not allowed in ISO C90
 // bad comment
 ^
gcctestcase01.c:1:1: warning: (this will be reported only once per input file)

However, many C projects disallow C++ style comments not for compatibility with
C90, but for style reasons. It'd be nice to be able to get this warning when
using newer language standards for such projects that disallow C++ style
comments anyways, especially now that GCC defaults to -std=gnu11 (meaning that
just adding -pedantic isn't enough). I suggest calling it -Wc++-style-comment.

Reply via email to