From dad2d3e003f1a9885cb1fa0f67baf50f62d57b06 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 26 Aug 2022 16:06:20 +0200 Subject: libcpp: Implement P2362R3 - Remove non-encodable wide character literals and multicharacter [PR106647] My understanding of the paper is that we just want to promote the CPP_WCHAR "character constant too long for its type" warning to error as it is already error for u8, u and U literals. 2022-08-26 Jakub Jelinek PR c++/106647 * charset.cc (wide_str_to_charconst): Implement P2362R3 - Remove non-encodable wide character literals and multicharacter. For C++23 use CPP_DL_ERROR instead of CPP_DL_WARNING for "character constant too long for its type" diagnostics on CPP_WCHAR literals. * g++.dg/cpp23/wchar-multi1.C: New test. * g++.dg/cpp23/wchar-multi2.C: New test. --- libcpp/charset.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libcpp') diff --git a/libcpp/charset.cc b/libcpp/charset.cc index 47a36d8..d3c07d6 100644 --- a/libcpp/charset.cc +++ b/libcpp/charset.cc @@ -2593,7 +2593,11 @@ wide_str_to_charconst (cpp_reader *pfile, cpp_string str, character constant is guaranteed to overflow. */ if (str.len > nbwc * 2) cpp_error (pfile, (CPP_OPTION (pfile, cplusplus) - && (type == CPP_CHAR16 || type == CPP_CHAR32)) + && (type == CPP_CHAR16 + || type == CPP_CHAR32 + /* In C++23 this is error even for L'ab'. */ + || (type == CPP_WCHAR + && CPP_OPTION (pfile, size_t_literals)))) ? CPP_DL_ERROR : CPP_DL_WARNING, "character constant too long for its type"); -- cgit v1.1