]> granicus.if.org Git - clang/commitdiff
Don't emit "will be treated as an identifier character" warning for
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Sep 2018 22:34:45 +0000 (22:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Sep 2018 22:34:45 +0000 (22:34 +0000)
UTF-8 characters that aren't identifier characters in the current
language mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp
test/Lexer/unicode.c

index 974414c1e45240563f07fb9f478c615849289351..35ba8c11eca6d18c93f9a3956f61ef494ebd8938 100644 (file)
@@ -3085,6 +3085,8 @@ bool Lexer::LexUnicode(Token &Result, uint32_t C, const char *CurPtr) {
       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);
     }
 
index bebab829880c196158869aad0a0638d8e785f78c..01285fbc2138078cae44d8f1d8349fc413554664 100644 (file)
@@ -45,3 +45,8 @@ int ⁠xx‍;
 // expected-warning@-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