aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-12-08 13:34:04 -0500
committerPatrick Palka <ppalka@redhat.com>2023-12-08 13:34:04 -0500
commit0c018a74eb1affe2a1fa385cdddaa93979683420 (patch)
treee35058436901600202f515918214925cbe05c70a /gcc
parent5764825aed613f201a8bc47e5b239027a39691f0 (diff)
downloadgcc-0c018a74eb1affe2a1fa385cdddaa93979683420.zip
gcc-0c018a74eb1affe2a1fa385cdddaa93979683420.tar.gz
gcc-0c018a74eb1affe2a1fa385cdddaa93979683420.tar.bz2
c++: guard more against undiagnosed error_mark_node [PR112658]
This adds a sanity check to cp_parser_expression_statement similar to the one in finish_expr_stmt added by r6-6795-g0fd9d4921f7ba2, which effectively downgrades accepts-invalid/wrong-code bugs like this one into ice-on-invalid/ice-on-valid ones. PR c++/112658 gcc/cp/ChangeLog: * parser.cc (cp_parser_expression_statement): If the statement is error_mark_node, make sure we've seen_error().
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/parser.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 732d2a9..6ec342c 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -12964,6 +12964,9 @@ cp_parser_expression_statement (cp_parser* parser, tree in_statement_expr)
if (statement == error_mark_node
&& !cp_parser_uncommitted_to_tentative_parse_p (parser))
{
+ /* If we ran into a problem, make sure we complained. */
+ gcc_assert (seen_error ());
+
cp_parser_skip_to_end_of_block_or_statement (parser);
return error_mark_node;
}