[gcc r14-8046] gccrs: Allow call to macro named "default" at item level

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:13:55 GMT 2024


https://gcc.gnu.org/g:1e039d2f848a97994f909e239a0d4e17f8933f46

commit r14-8046-g1e039d2f848a97994f909e239a0d4e17f8933f46
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Tue Oct 10 14:36:35 2023 +0200

    gccrs: Allow call to macro named "default" at item level
    
    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>

Diff:
---
 gcc/rust/parse/rust-parse-impl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index dde3d63201e..1a042661568 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -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",


More information about the Gcc-cvs mailing list