зеркало из https://github.com/microsoft/clang-1.git
implement -Wmultichar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70315 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
660a5ac8ec
Коммит
b77f41e66f
|
@ -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,
|
||||
|
|
|
@ -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<
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче