implement -Wmultichar


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70315 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index 073b4a0..c0afde5 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -43,6 +43,7 @@
 def : DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
 def : DiagGroup<"missing-noreturn">;
+def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
 def : DiagGroup<"newline-eof">;
 def : DiagGroup<"format-y2k">;
@@ -94,6 +95,7 @@
 def Most : DiagGroup<"most", [
     Comment,
     Implicit,
+    MultiChar,
     Switch,
     Trigraphs,
     Uninitialized,
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td
index b2e99df..471b136 100644
--- a/include/clang/Basic/DiagnosticLexKinds.td
+++ b/include/clang/Basic/DiagnosticLexKinds.td
@@ -51,6 +51,8 @@
 def err_unterminated_block_comment : Error<"unterminated /* comment">;
 def err_invalid_character_to_charify : Error<
   "invalid argument to convert to character">;
+def ext_multichar_character_literal : ExtWarn<
+  "multi-character character constant">, InGroup<MultiChar>;
 
 // Literal
 def ext_nonstandard_escape : Extension<
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index 03ecff9..faa44b6 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -662,6 +662,8 @@
         // constants (L'abcd').
         if (IsWide)
           PP.Diag(Loc, diag::warn_extraneous_wide_char_constant);
+        else
+          PP.Diag(Loc, diag::ext_multichar_character_literal);
       }
 
       if (IsWide) {
@@ -671,7 +673,6 @@
         // Narrow character literals act as though their value is concatenated
         // in this implementation.
         if ((LitVal.shl(8)).lshr(8) != LitVal)
-        // if (((LitVal << 8) >> 8) != LitVal)
           PP.Diag(Loc, diag::warn_char_constant_too_large);
         LitVal <<= 8;
       }
diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c
index c046581..f5fc9e1 100644
--- a/test/Lexer/constants.c
+++ b/test/Lexer/constants.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify -pedantic -trigraphs %s
 
 int x = 000000080;  // expected-error {{invalid digit}}
 
@@ -13,3 +13,17 @@
 // PR2252
 #if -0x8000000000000000  // should not warn.
 #endif
+
+
+char c[] = {
+  'df',  // expected-warning {{multi-character character constant}}
+  '\t',
+  '\\
+t',
+  '??!'  // expected-warning {{trigraph converted to '|' character}}
+};
+
+
+#pragma GCC diagnostic ignored "-Wmultichar"
+
+char d = 'df'; // no warning.