[clang] 8fa45e1 - Convert diagnostics about multi-character literals from extension to warning

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 05:47:33 PDT 2020


Author: Chuyang Chen
Date: 2020-10-06T08:47:17-04:00
New Revision: 8fa45e1fd527269140c4e2a1652fef5500da16fd

URL: https://github.com/llvm/llvm-project/commit/8fa45e1fd527269140c4e2a1652fef5500da16fd
DIFF: https://github.com/llvm/llvm-project/commit/8fa45e1fd527269140c4e2a1652fef5500da16fd.diff

LOG: Convert diagnostics about multi-character literals from extension to warning

This addresses PR46797.

Added: 
    clang/test/Lexer/multi-char-constants.c

Modified: 
    clang/include/clang/Basic/DiagnosticLexKinds.td
    clang/lib/Lex/LiteralSupport.cpp
    clang/test/Lexer/constants.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 77d2e26ba790..130e7687bad2 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -104,10 +104,10 @@ def warn_cxx98_compat_raw_string_literal : Warning<
   "raw string literals are incompatible with C++98">,
   InGroup<CXX98Compat>, DefaultIgnore;
 
-def ext_multichar_character_literal : ExtWarn<
+def warn_multichar_character_literal : Warning<
   "multi-character character constant">, InGroup<MultiChar>;
-def ext_four_char_character_literal : Extension<
-  "multi-character character constant">, InGroup<FourByteMultiChar>;
+def warn_four_char_character_literal : Warning<
+  "multi-character character constant">, InGroup<FourByteMultiChar>, DefaultIgnore;
 
 
 // Unicode and UCNs

diff  --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index eb16bc8c7da2..6c3cdbdf6492 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1373,9 +1373,9 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
     if (isWide())
       PP.Diag(Loc, diag::warn_extraneous_char_constant);
     else if (isAscii() && NumCharsSoFar == 4)
-      PP.Diag(Loc, diag::ext_four_char_character_literal);
+      PP.Diag(Loc, diag::warn_four_char_character_literal);
     else if (isAscii())
-      PP.Diag(Loc, diag::ext_multichar_character_literal);
+      PP.Diag(Loc, diag::warn_multichar_character_literal);
     else
       PP.Diag(Loc, diag::err_multichar_utf_character_literal);
     IsMultiChar = true;

diff  --git a/clang/test/Lexer/constants.c b/clang/test/Lexer/constants.c
index 9c84ddc01929..caa373720942 100644
--- a/clang/test/Lexer/constants.c
+++ b/clang/test/Lexer/constants.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -ftrigraphs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wfour-char-constants -pedantic -ftrigraphs %s
 
 int x = 000000080;  // expected-error {{invalid digit}}
 

diff  --git a/clang/test/Lexer/multi-char-constants.c b/clang/test/Lexer/multi-char-constants.c
new file mode 100644
index 000000000000..3281c68d1fb2
--- /dev/null
+++ b/clang/test/Lexer/multi-char-constants.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wfour-char-constants -pedantic-errors %s
+
+int x = 'ab'; // expected-warning {{multi-character character constant}}
+int y = 'abcd'; // expected-warning {{multi-character character constant}}


        


More information about the cfe-commits mailing list