aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.cc
diff options
context:
space:
mode:
authorSimon Martin <simon@nasilyan.com>2024-06-07 11:21:07 +0200
committerSimon Martin <simon@nasilyan.com>2024-06-08 13:08:12 +0200
commit2c9643c27ecddb7f597d34009d89e932b4aca58e (patch)
treee04897fed77b40e924c0a775483391e9d4300113 /gcc/cp/parser.cc
parentde05e44b2ad9638d04173393b1eae3c38b2c3864 (diff)
downloadgcc-2c9643c27ecddb7f597d34009d89e932b4aca58e.zip
gcc-2c9643c27ecddb7f597d34009d89e932b4aca58e.tar.gz
gcc-2c9643c27ecddb7f597d34009d89e932b4aca58e.tar.bz2
c++: Make *_cast<*> parsing more robust to errors [PR108438]
We ICE upon the following when trying to emit a -Wlogical-not-parentheses warning: === cut here === template <typename T> T foo (T arg, T& ref, T* ptr) { int a = 1; return static_cast<T!>(a); } === cut here === This patch makes *_cast<*> parsing more robust by skipping to the closing '>' upon error in the target type. Successfully tested on x86_64-pc-linux-gnu. PR c++/108438 gcc/cp/ChangeLog: * parser.cc (cp_parser_postfix_expression): Use cp_parser_require_end_of_template_parameter_list to skip to the closing '>' upon error parsing the target type of *_cast<*> expressions. gcc/testsuite/ChangeLog: * g++.dg/parse/crash75.C: New test.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r--gcc/cp/parser.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index bc4a235..9f43a77 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -7569,7 +7569,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
NULL);
parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
/* Look for the closing `>'. */
- cp_parser_require (parser, CPP_GREATER, RT_GREATER);
+ cp_parser_require_end_of_template_parameter_list (parser);
/* Restore the old message. */
parser->type_definition_forbidden_message = saved_message;