diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1652,7 +1652,8 @@ 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), @@ -1691,7 +1692,8 @@ 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); diff --git a/clang/test/Lexer/unicode.c b/clang/test/Lexer/unicode.c --- a/clang/test/Lexer/unicode.c +++ b/clang/test/Lexer/unicode.c @@ -1,5 +1,6 @@ // 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 -triple x86_64-scei-ps4 -E -DPP_ONLY=1 %s -o %t // RUN: %clang_cc1 -E -DPP_ONLY=1 %s -o %t // RUN: FileCheck --strict-whitespace --input-file=%t %s