aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2025-08-01 21:27:28 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:37:03 +0200
commit2f054b8db9fa548443560a1187c998945fc9634a (patch)
tree9c9fd3a28d7f63007aea08328f3bf8d664a21807
parent715849d86f8645c059ef18172eb6a481ba53ef91 (diff)
downloadgcc-2f054b8db9fa548443560a1187c998945fc9634a.zip
gcc-2f054b8db9fa548443560a1187c998945fc9634a.tar.gz
gcc-2f054b8db9fa548443560a1187c998945fc9634a.tar.bz2
gccrs: Catch parse failure in parse_path_meta_item
gcc/rust/ChangeLog: * ast/rust-ast.cc (AttributeParser::parse_path_meta_item): Catch parse_expr returning nullptr and remove defunct comment. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
-rw-r--r--gcc/rust/ast/rust-ast.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 8918ef8..fd371ea 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -3713,9 +3713,12 @@ AttributeParser::parse_path_meta_item ()
skip_token ();
std::unique_ptr<Expr> expr = parser->parse_expr ();
- // stream_pos++;
- /* shouldn't be required anymore due to parsing literal actually
- * skipping the token */
+
+ // handle error
+ // parse_expr should already emit an error and return nullptr
+ if (!expr)
+ return nullptr;
+
return std::unique_ptr<MetaItemPathExpr> (
new MetaItemPathExpr (std::move (path), std::move (expr)));
}