summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-04-18 00:46:59 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-04-28 11:09:16 +0000
commitfef6c560017c33a4d5e439067bad09a85630f851 (patch)
tree81ed020201a97028d60266a2a1ea7afbec409f2e
parentaaf7336dfaece0120c0daff483d60299e7cf2200 (diff)
downloadgcc-fef6c560017c33a4d5e439067bad09a85630f851.tar.gz
Fix infinite loop with parsing invalid generic parameters
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_params): Handle parameter parsing error. gcc/testsuite/ChangeLog: * rust/compile/issue-2125.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
-rw-r--r--gcc/rust/parse/rust-parse-impl.h2
-rw-r--r--gcc/testsuite/rust/compile/issue-2125.rs2
2 files changed, 4 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 2609e5ae94b..1bb3a9a356e 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -3127,6 +3127,8 @@ Parser<ManagedTokenSource>::parse_generic_params (EndTokenPred is_end_token)
generic_params.emplace_back (std::move (param));
maybe_skip_token (COMMA);
}
+ else
+ break;
}
// FIXME: Add reordering hint
diff --git a/gcc/testsuite/rust/compile/issue-2125.rs b/gcc/testsuite/rust/compile/issue-2125.rs
new file mode 100644
index 00000000000..cbcf4cb133f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2125.rs
@@ -0,0 +1,2 @@
+// { dg-timeout 5 }
+struct S<$>; // { dg-error ".*" }