https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105300
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:9f353b0c1dc9385ba8b8a64b65d66d5452383c11 commit r13-5390-g9f353b0c1dc9385ba8b8a64b65d66d5452383c11 Author: Marek Polacek <pola...@redhat.com> Date: Fri Nov 11 17:59:30 2022 -0500 c++: Reject UDLs in certain contexts [PR105300] In this PR, we are crashing because we've encountered a UDL where a string-literal is expected. This patch makes the parser reject string and character UDLs in all places where the grammar requires a string-literal and not a user-defined-string-literal. I've introduced two new wrappers; the existing cp_parser_string_literal was renamed to cp_parser_string_literal_common and should not be called directly. finish_userdef_string_literal is renamed from cp_parser_userdef_string_literal. PR c++/105300 gcc/c-family/ChangeLog: * c-pragma.cc (handle_pragma_message): Warn for CPP_STRING_USERDEF. gcc/cp/ChangeLog: * parser.cc: Remove unnecessary forward declarations. (cp_parser_string_literal): New wrapper. (cp_parser_string_literal_common): Renamed from cp_parser_string_literal. Add a bool parameter. Give an error when UDLs are not permitted. (cp_parser_userdef_string_literal): New wrapper. (finish_userdef_string_literal): Renamed from cp_parser_userdef_string_literal. (cp_parser_primary_expression): Call cp_parser_userdef_string_literal instead of cp_parser_string_literal. (cp_parser_linkage_specification): Move a variable declaration closer to its first use. (cp_parser_static_assert): Likewise. (cp_parser_operator): Call cp_parser_userdef_string_literal instead of cp_parser_string_literal. (cp_parser_asm_definition): Move a variable declaration closer to its first use. (cp_parser_asm_specification_opt): Move variable declarations closer to their first use. (cp_parser_asm_operand_list): Likewise. (cp_parser_asm_clobber_list): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/udlit-error1.C: New test.