Skip to content

Commit

Permalink
Do not emit diagnostics for invalid unicode characters in preprocessi…
Browse files Browse the repository at this point in the history
  • Loading branch information
cor3ntin authored and AaronBallman committed Aug 18, 2021
1 parent 7338be0 commit 2715c4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions clang/lib/Lex/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,8 @@ bool Lexer::tryConsumeIdentifierUCN(const char *&CurPtr, unsigned Size,
if (!isAllowedIDChar(CodePoint, LangOpts)) {
if (isASCII(CodePoint) || isUnicodeWhitespace(CodePoint))
return false;
if (!isLexingRawMode())
if (!isLexingRawMode() && !ParsingPreprocessorDirective &&
!PP->isPreprocessedOutput())
diagnoseInvalidUnicodeCodepointInIdentifier(
PP->getDiagnostics(), LangOpts, CodePoint,
makeCharRange(*this, CurPtr, UCNPtr),
Expand Down Expand Up @@ -1691,7 +1692,8 @@ bool Lexer::tryConsumeIdentifierUTF8Char(const char *&CurPtr) {
if (isASCII(CodePoint) || isUnicodeWhitespace(CodePoint))
return false;

if (!isLexingRawMode())
if (!isLexingRawMode() && !ParsingPreprocessorDirective &&
!PP->isPreprocessedOutput())
diagnoseInvalidUnicodeCodepointInIdentifier(
PP->getDiagnostics(), LangOpts, CodePoint,
makeCharRange(*this, CurPtr, UnicodePtr), /*IsFirst=*/false);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Lexer/unicode.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
// RUN: %clang_cc1 -E -DPP_ONLY=1 %s -o %t
// RUN: FileCheck --strict-whitespace --input-file=%t %s
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
// RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace

// This file contains Unicode characters; please do not "fix" them!

Expand Down

0 comments on commit 2715c4d

Please sign in to comment.