]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Catch parse failure in parse_path_meta_item
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 2 Aug 2025 01:27:28 +0000 (21:27 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:37:03 +0000 (16:37 +0200)
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>
gcc/rust/ast/rust-ast.cc

index 8918ef8a0073966ceef36ce8499eb6702539f5a8..fd371ea0cd99f2b61b69031fe714fe034980f660 100644 (file)
@@ -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)));
       }