aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-03-18 11:34:39 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-03-18 12:40:05 +0100
commita64a5cf77c9685aa623ec69168e7f50324a102b9 (patch)
treeba9b636d9a2a21c4abaa2410d5efd20ac724fe87 /gcc/rust/parse
parent1bb9a29688ab4ddfec7f8d36ca2cee63c5f258d2 (diff)
downloadgcc-a64a5cf77c9685aa623ec69168e7f50324a102b9.zip
gcc-a64a5cf77c9685aa623ec69168e7f50324a102b9.tar.gz
gcc-a64a5cf77c9685aa623ec69168e7f50324a102b9.tar.bz2
macros: Do not propagate parse errors in match repetitions
Since parsing repetitions is very eager, the parser might accumulate bogus errors by trying to match more repetitions than there are. We can avoid this by clearing the parsing errors if parsing repetitions returned a valid result. This should not be an issue for previous matchers erroring out, as they would immediately return upon failure and not reach inside other match functions.
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r--gcc/rust/parse/rust-parse.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 5880616..9a31fb6 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -649,7 +649,6 @@ private:
bool done_end_of_file ();
void add_error (Error error) { error_table.push_back (std::move (error)); }
- void clear_errors () { error_table.clear (); }
public:
// Construct parser with specified "managed" token source.
@@ -668,6 +667,8 @@ public:
// Returns whether any parsing errors have occurred.
bool has_errors () const { return !error_table.empty (); }
+ // Remove all parsing errors from the table
+ void clear_errors () { error_table.clear (); }
// Get a reference to the list of errors encountered
std::vector<Error> &get_errors () { return error_table; }