Skip to content

Commit f6dff93

Browse files
committed
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
1 parent eb3136f commit f6dff93

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ Bug Fixes
147147
because there is no way to fully qualify the enumerator name, so this
148148
"extension" was unintentional and useless. This fixes
149149
`Issue 42372 <https://github.com/llvm/llvm-project/issues/42372>`_.
150+
- Now correctly diagnose use of ``//`` comments in ``gnu89`` mode (which
151+
matches the behavior of GCC) in addition to ``c89`` mode. This fixes
152+
`Issue 18427 <https://github.com/llvm/llvm-project/issues/18427>`_.
150153

151154
Improvements to Clang's diagnostics
152155
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/LangStandards.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ LANGSTANDARD(c94, "iso9899:199409",
4646

4747
LANGSTANDARD(gnu89, "gnu89",
4848
C, "ISO C 1990 with GNU extensions",
49-
LineComment | Digraphs | GNUMode)
49+
Digraphs | GNUMode)
5050
LANGSTANDARD_ALIAS(gnu89, "gnu90")
5151

5252
// C99-ish modes

clang/test/Lexer/c90.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* RUN: %clang_cc1 -std=c90 -fsyntax-only %s -verify -pedantic-errors
22
*/
3+
/* RUN: %clang_cc1 -std=gnu89 -fsyntax-only %s -verify -pedantic-errors
4+
*/
35

46
enum { cast_hex = (long) (
57
0x0p-1 /* expected-error {{hexadecimal floating constants are a C99 feature}} */

clang/test/Sema/gnu89.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
1+
/* RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
2+
*/
23

34
int f(int restrict);
45

5-
void main(void) {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}
6+
void main(void) {} /* expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}} */

0 commit comments

Comments
 (0)