From: Jason Merrill Date: Tue, 8 Jun 2021 18:38:42 +0000 (-0400) Subject: c++: Test for mixed string literal concatenation X-Git-Tag: basepoints/gcc-13~7007 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=924e02553af64b10c485711d635c0bc0265a8743;p=thirdparty%2Fgcc.git c++: Test for mixed string literal concatenation From wg21.link/p2201r1 gcc/cp/ChangeLog: * parser.c (cp_parser_string_literal): Adjust diagnostic. gcc/testsuite/ChangeLog: * g++.dg/cpp23/mixed-concat1.C: New test. --- diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 24f248af11ce..d59a829d0b9e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4378,8 +4378,8 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok, rich_location rich_loc (line_table, tok->location); rich_loc.add_range (last_tok_loc); error_at (&rich_loc, - "unsupported non-standard concatenation " - "of string literals"); + "concatenation of string literals with " + "conflicting encoding prefixes"); } } diff --git a/gcc/testsuite/g++.dg/cpp23/mixed-concat1.C b/gcc/testsuite/g++.dg/cpp23/mixed-concat1.C new file mode 100644 index 000000000000..d69fafc862d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/mixed-concat1.C @@ -0,0 +1,21 @@ +// Test from P2201R1 +// { dg-do compile { target c++11 } } + +void f() { + + { auto a = L"" u""; } // { dg-error "concatenation" } + { auto a = L"" u8""; } // { dg-error "concatenation" } + { auto a = L"" U""; } // { dg-error "concatenation" } + + { auto a = u8"" L""; } // { dg-error "concatenation" } + { auto a = u8"" u""; } // { dg-error "concatenation" } + { auto a = u8"" U""; } // { dg-error "concatenation" } + + { auto a = u"" L""; } // { dg-error "concatenation" } + { auto a = u"" u8""; } // { dg-error "concatenation" } + { auto a = u"" U""; } // { dg-error "concatenation" } + + { auto a = U"" L""; } // { dg-error "concatenation" } + { auto a = U"" u""; } // { dg-error "concatenation" } + { auto a = U"" u8""; } // { dg-error "concatenation" } +}