r343040 - Don't emit "will be treated as an identifier character" warning for
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 25 15:34:45 PDT 2018
Author: rsmith
Date: Tue Sep 25 15:34:45 2018
New Revision: 343040
URL: http://llvm.org/viewvc/llvm-project?rev=343040&view=rev
Log:
Don't emit "will be treated as an identifier character" warning for
UTF-8 characters that aren't identifier characters in the current
language mode.
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Lexer/unicode.c
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=343040&r1=343039&r2=343040&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Sep 25 15:34:45 2018
@@ -3085,6 +3085,8 @@ bool Lexer::LexUnicode(Token &Result, ui
maybeDiagnoseIDCharCompat(PP->getDiagnostics(), C,
makeCharRange(*this, BufferPtr, CurPtr),
/*IsFirst=*/true);
+ maybeDiagnoseUTF8Homoglyph(PP->getDiagnostics(), C,
+ makeCharRange(*this, BufferPtr, CurPtr));
}
MIOpt.ReadToken();
@@ -3879,7 +3881,6 @@ LexNextToken:
// We can't just reset CurPtr to BufferPtr because BufferPtr may point to
// an escaped newline.
--CurPtr;
- const char *UTF8StartPtr = CurPtr;
llvm::ConversionResult Status =
llvm::convertUTF8Sequence((const llvm::UTF8 **)&CurPtr,
(const llvm::UTF8 *)BufferEnd,
@@ -3894,9 +3895,6 @@ LexNextToken:
// (We manually eliminate the tail call to avoid recursion.)
goto LexNextToken;
}
- if (!isLexingRawMode())
- maybeDiagnoseUTF8Homoglyph(PP->getDiagnostics(), CodePoint,
- makeCharRange(*this, UTF8StartPtr, CurPtr));
return LexUnicode(Result, CodePoint, CurPtr);
}
Modified: cfe/trunk/test/Lexer/unicode.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/unicode.c?rev=343040&r1=343039&r2=343040&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/unicode.c (original)
+++ cfe/trunk/test/Lexer/unicode.c Tue Sep 25 15:34:45 2018
@@ -45,3 +45,8 @@ int â xxâ;
// expected-warning at -3 {{identifier contains Unicode character <U+200D> that is invisible in some environments}}
int fooâbar = 0; // expected-warning {{identifier contains Unicode character <U+200B> that is invisible in some environments}}
int x = foobar; // expected-error {{undeclared identifier}}
+
+int â£foo; // expected-error {{non-ASCII character}}
+#ifndef PP_ONLY
+#define ⶠx // expected-error {{macro name must be an identifier}}
+#endif
More information about the cfe-commits
mailing list