Skip to content

Commit d4888e1

Browse files
powerboat9philberty
authored andcommitted
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 <[email protected]>
1 parent 3df53dd commit d4888e1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gcc/rust/ast/rust-ast.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3713,9 +3713,12 @@ AttributeParser::parse_path_meta_item ()
37133713
skip_token ();
37143714

37153715
std::unique_ptr<Expr> expr = parser->parse_expr ();
3716-
// stream_pos++;
3717-
/* shouldn't be required anymore due to parsing literal actually
3718-
* skipping the token */
3716+
3717+
// handle error
3718+
// parse_expr should already emit an error and return nullptr
3719+
if (!expr)
3720+
return nullptr;
3721+
37193722
return std::unique_ptr<MetaItemPathExpr> (
37203723
new MetaItemPathExpr (std::move (path), std::move (expr)));
37213724
}

0 commit comments

Comments
 (0)