Index: clang/lib/Lex/Lexer.cpp =================================================================== --- clang/lib/Lex/Lexer.cpp +++ clang/lib/Lex/Lexer.cpp @@ -3459,7 +3459,7 @@ MIOpt.ReadToken(); return LexNumericConstant(Result, CurPtr); - case 'u': // Identifier (uber) or C11/C++11 UTF-8 or UTF-16 string literal + case 'u': // Identifier (uber) or C11/C2x/C++11 UTF-8 or UTF-16 string literal // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); @@ -3493,7 +3493,7 @@ ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result), tok::utf8_string_literal); - if (Char2 == '\'' && LangOpts.CPlusPlus17) + if (Char2 == '\'' && (LangOpts.CPlusPlus17 || LangOpts.C2x)) return LexCharConstant( Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result), Index: clang/test/Lexer/utf8-char-literal.cpp =================================================================== --- clang/test/Lexer/utf8-char-literal.cpp +++ clang/test/Lexer/utf8-char-literal.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c2x -DC2X -x c -fsyntax-only -verify %s // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++1z -fsyntax-only -verify %s int array0[u'ñ' == u'\xf1'? 1 : -1]; @@ -12,4 +13,12 @@ char d = u8'\u1234'; // expected-error {{character too large for enclosing character literal type}} char e = u8'ሴ'; // expected-error {{character too large for enclosing character literal type}} char f = u8'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} +#elif defined(C2X) +char a = u8'ñ'; // expected-error {{character too large for enclosing character literal type}} +unsigned char b = u8'\x80'; // ok +char c = u8'\u0080'; // expected-error {{universal character name refers to a control character}} +char d = u8'\u1234'; // expected-error {{character too large for enclosing character literal type}} +char e = u8'ሴ'; // expected-error {{character too large for enclosing character literal type}} +char f = u8'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} +char g = u8'\x80'; // expected-warning {{implicit conversion from 'int' to 'char' changes value from 128 to -128}} #endif