[clang] 1c50909 - Revert "Pedantically warn about // comments in gnu89 mode"

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 15:42:56 PDT 2022


Author: Aaron Ballman
Date: 2022-05-05T18:39:13-04:00
New Revision: 1c50909f6f8ac183b82e973457522439a8856e96

URL: https://github.com/llvm/llvm-project/commit/1c50909f6f8ac183b82e973457522439a8856e96
DIFF: https://github.com/llvm/llvm-project/commit/1c50909f6f8ac183b82e973457522439a8856e96.diff

LOG: Revert "Pedantically warn about // comments in gnu89 mode"

This reverts commit f6dff93641b2259623e686eb13a1884b8b9f4a00.

This diagnostic is also in the -Wcomment group, which is in the -Wall
group, so the diagnostic is enabled in a wider context than GCC does.
That turns out to be disruptive for the Linux kernel builds still using
-std=gnu89 because the kernel requires C source files to start with //
comments: https://kernel.org/doc/html/v5.18-rc5/process/license-rules.html#license-identifier-syntax

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/LangStandards.def
    clang/test/Lexer/c90.c
    clang/test/Sema/gnu89.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 47abde0747d6f..119d6eb95f454 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -147,9 +147,6 @@ Bug Fixes
   because there is no way to fully qualify the enumerator name, so this
   "extension" was unintentional and useless. This fixes
   `Issue 42372 <https://github.com/llvm/llvm-project/issues/42372>`_.
-- Now correctly diagnose use of ``//`` comments in ``gnu89`` mode (which
-  matches the behavior of GCC) in addition to ``c89`` mode. This fixes
-  `Issue 18427 <https://github.com/llvm/llvm-project/issues/18427>`_.
 
 Improvements to Clang's diagnostics
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

diff  --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def
index d4e42b4cd6d86..323032f41da02 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -46,7 +46,7 @@ LANGSTANDARD(c94, "iso9899:199409",
 
 LANGSTANDARD(gnu89, "gnu89",
              C, "ISO C 1990 with GNU extensions",
-             Digraphs | GNUMode)
+             LineComment | Digraphs | GNUMode)
 LANGSTANDARD_ALIAS(gnu89, "gnu90")
 
 // C99-ish modes

diff  --git a/clang/test/Lexer/c90.c b/clang/test/Lexer/c90.c
index 39ffdc170b108..8752404c1c199 100644
--- a/clang/test/Lexer/c90.c
+++ b/clang/test/Lexer/c90.c
@@ -1,7 +1,5 @@
 /* RUN: %clang_cc1 -std=c90 -fsyntax-only %s -verify -pedantic-errors
  */
-/* RUN: %clang_cc1 -std=gnu89 -fsyntax-only %s -verify -pedantic-errors
- */
 
 enum { cast_hex = (long) (
       0x0p-1   /* expected-error {{hexadecimal floating constants are a C99 feature}} */

diff  --git a/clang/test/Sema/gnu89.c b/clang/test/Sema/gnu89.c
index d96d3536fbfff..1be717f54260e 100644
--- a/clang/test/Sema/gnu89.c
+++ b/clang/test/Sema/gnu89.c
@@ -1,6 +1,5 @@
-/* RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
- */
+// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
 
 int f(int restrict);
 
-void main(void) {} /* expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}} */
+void main(void) {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}


        


More information about the cfe-commits mailing list