diff options
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 2 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticLexKinds.td | 2 | ||||
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/constants.c | 16 |
4 files changed, 21 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 073b4a0cb2..c0afde52d3 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -43,6 +43,7 @@ def : DiagGroup<"missing-braces">; 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 : DiagGroup<"", [Extra]>; // -W = -Wextra 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 b2e99df9de..471b136873 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -51,6 +51,8 @@ def err_empty_character : Error<"empty character constant">; 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 03ecff91a5..faa44b6fb0 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -662,6 +662,8 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, // 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 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, // 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 c046581633..f5fc9e1493 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 @@ float Y = 08.123456; // 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. |