]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Allow call to macro named "default" at item level
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 10 Oct 2023 12:36:35 +0000 (14:36 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:09:15 +0000 (19:09 +0100)
The parser was too agressive and did reject any line beginning with
default even if this was a macro call.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_item): Relax constraints
around default identifier at item scope to accept "default" macros.

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

index dde3d63201e2792db584cfc6240498e5293207c1..1a042661568bc8e8559eae45dea0d83e2f1ddda8 100644 (file)
@@ -1133,7 +1133,8 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
          return parse_vis_item (std::move (outer_attrs));
          // or should this go straight to parsing union?
        }
-      else if (t->get_str () == "default")
+      else if (t->get_str () == "default"
+              && lexer.peek_token (1)->get_id () != EXCLAM)
        {
          add_error (Error (t->get_locus (),
                            "%qs is only allowed on items within %qs blocks",