From: Corentin Jabot Date: Wed, 18 Aug 2021 13:10:34 +0000 (-0400) Subject: Do not emit diagnostics for invalid unicode characters in preprocessing mode X-Git-Tag: upstream/15.0.7~33623 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2715c4da50387ed6dae49a2a17fdcfad8a769a3c;p=platform%2Fupstream%2Fllvm.git Do not emit diagnostics for invalid unicode characters in preprocessing mode This amends 4e80636db71a1b6123d15ed1f9eda3979b4292de with a fix for https://lab.llvm.org/buildbot/#/builders/139/builds/8943 --- diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index d1555b4..05b84e0 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -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), @@ -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); diff --git a/clang/test/Lexer/unicode.c b/clang/test/Lexer/unicode.c index fb974a4..3d64488 100644 --- a/clang/test/Lexer/unicode.c +++ b/clang/test/Lexer/unicode.c @@ -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!