[clang] f6dff93 - Pedantically warn about // comments in gnu89 mode
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu May 5 11:35:56 PDT 2022
Author: Aaron Ballman
Date: 2022-05-05T14:35:47-04:00
New Revision: f6dff93641b2259623e686eb13a1884b8b9f4a00
URL: https://github.com/llvm/llvm-project/commit/f6dff93641b2259623e686eb13a1884b8b9f4a00
DIFF: https://github.com/llvm/llvm-project/commit/f6dff93641b2259623e686eb13a1884b8b9f4a00.diff
LOG: Pedantically warn about // comments in gnu89 mode
GCC warns with a pedantic warning when -std=gnu89, but Clang would only
diagnose in -std=c89 mode. Clang now matches the GCC behavior in both
modes.
Fixes #18427
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 87e4df50ae0f2..090b4c6b1b6c6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -147,6 +147,9 @@ 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 323032f41da02..d4e42b4cd6d86 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",
- LineComment | Digraphs | GNUMode)
+ Digraphs | GNUMode)
LANGSTANDARD_ALIAS(gnu89, "gnu90")
// C99-ish modes
diff --git a/clang/test/Lexer/c90.c b/clang/test/Lexer/c90.c
index 8752404c1c199..39ffdc170b108 100644
--- a/clang/test/Lexer/c90.c
+++ b/clang/test/Lexer/c90.c
@@ -1,5 +1,7 @@
/* 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 1be717f54260e..d96d3536fbfff 100644
--- a/clang/test/Sema/gnu89.c
+++ b/clang/test/Sema/gnu89.c
@@ -1,5 +1,6 @@
-// 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