public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8866] gccrs: Fix macro parsing for trait items.
@ 2024-02-07 12:45 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-02-07 12:45 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:af3f0482367232d2d655e51bee382e98ddbfb117
commit r14-8866-gaf3f0482367232d2d655e51bee382e98ddbfb117
Author: Kushal Pal <kushalpal109@gmail.com>
Date: Fri Jan 26 18:35:59 2024 +0530
gccrs: Fix macro parsing for trait items.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_trait_item):
Handle macros in trait items similar to how its handled for trait
implementation items.
Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diff:
---
gcc/rust/parse/rust-parse-impl.h | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index ed264371db7f..ac1754542d43 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -5094,6 +5094,18 @@ Parser<ManagedTokenSource>::parse_trait_item ()
const_TokenPtr tok = lexer.peek_token ();
switch (tok->get_id ())
{
+ case SUPER:
+ case SELF:
+ case CRATE:
+ case DOLLAR_SIGN:
+ // these seem to be SimplePath tokens, so this is a macro invocation
+ // semi
+ return parse_macro_invocation_semi (std::move (outer_attrs));
+ case IDENTIFIER:
+ if (lexer.peek_token ()->get_str () == Values::WeakKeywords::DEFAULT)
+ return parse_function (std::move (vis), std::move (outer_attrs));
+ else
+ return parse_macro_invocation_semi (std::move (outer_attrs));
case TYPE:
return parse_trait_type (std::move (outer_attrs), vis);
case CONST:
@@ -5110,25 +5122,14 @@ Parser<ManagedTokenSource>::parse_trait_item ()
case EXTERN_KW:
case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
-
- default: {
- // TODO: try and parse macro invocation semi - if fails, maybe error.
- std::unique_ptr<AST::TraitItem> macro_invoc
- = parse_macro_invocation_semi (outer_attrs);
-
- if (macro_invoc == nullptr)
- {
- // TODO: error?
- return nullptr;
- }
- else
- {
- return macro_invoc;
- }
- /* FIXME: macro invocations can only start with certain tokens. be
- * more picky with these? */
- }
+ default:
+ break;
}
+ add_error (Error (tok->get_locus (),
+ "unrecognised token %qs for item in trait",
+ tok->get_token_description ()));
+ // skip?
+ return nullptr;
}
// Parse a typedef trait item.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-07 12:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 12:45 [gcc r14-8866] gccrs: Fix macro parsing for trait items Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).