public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7996] gccrs: Retrieve def for derive & attribute proc macros
@ 2024-01-16 18:12 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:91461d3e7335aecbdfc821acdbe48b8556434965
commit r14-7996-g91461d3e7335aecbdfc821acdbe48b8556434965
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Tue Aug 29 15:59:58 2023 +0200
gccrs: Retrieve def for derive & attribute proc macros
Add definition retrieval for derive and attribute proc macro types.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
Add proc macro handle retrieval for attribute and derive proc macros.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 7373e623266..57a38078f14 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -177,6 +177,8 @@ Early::visit (AST::UseTreeGlob &use)
void
Early::visit_attributes (std::vector<AST::Attribute> &attrs)
{
+ auto mappings = Analysis::Mappings::get ();
+
for (auto &attr : attrs)
{
auto name = attr.get_path ().get_segments ().at (0).get_segment_name ();
@@ -192,7 +194,16 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
// FIXME: Change to proper error message
rust_error_at (trait.get ().get_locus (),
"could not resolve trait");
+ continue;
}
+
+ auto pm_def
+ = mappings->lookup_derive_proc_macro_def (definition.value ());
+
+ rust_assert (pm_def.has_value ());
+
+ mappings->insert_derive_proc_macro_invocation (trait,
+ pm_def.value ());
}
}
else if (Analysis::BuiltinAttributeMappings::get ()
@@ -207,6 +218,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
"could not resolve attribute macro invocation");
return;
}
+ auto pm_def
+ = mappings->lookup_attribute_proc_macro_def (definition.value ());
+
+ rust_assert (pm_def.has_value ());
+
+ mappings->insert_attribute_proc_macro_invocation (attr.get_path (),
+ pm_def.value ());
}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:12 [gcc r14-7996] gccrs: Retrieve def for derive & attribute proc macros 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).