]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix RangeFromExpr parsing in for loops
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 10 Oct 2023 11:11:55 +0000 (13:11 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:09:16 +0000 (19:09 +0100)
Those ranges were looking for a curly brace after the brace, leading
to an error when using range from expr in for loops.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_expr): Fix range from expr.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/parse/rust-parse-impl.h

index 1a042661568bc8e8559eae45dea0d83e2f1ddda8..63dea9836df8eab97a03bd049e0c199f11997960 100644 (file)
@@ -22,6 +22,7 @@
 /* DO NOT INCLUDE ANYWHERE - this is automatically included with rust-parse.h
  * This is also the reason why there are no include guards. */
 
+#include "rust-token.h"
 #define INCLUDE_ALGORITHM
 #include "rust-diagnostics.h"
 #include "rust-make-unique.h"
@@ -12089,7 +12090,7 @@ Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
     {
       TokenId id = current_token->get_id ();
       if (id == SEMICOLON || id == RIGHT_PAREN || id == RIGHT_CURLY
-         || id == RIGHT_SQUARE || id == COMMA)
+         || id == RIGHT_SQUARE || id == COMMA || id == LEFT_CURLY)
        return nullptr;
     }