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.
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;
--- /dev/null
+// PR c++/108438
+// { dg-options "-Wlogical-not-parentheses" }
+
+template <typename T>
+T foo (T arg, T& ref, T* ptr)
+{
+ int a = 1;
+ return static_cast<T!>(a); // { dg-error "expected" }
+}