aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-session-manager.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-08-08 12:16:44 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:00:34 +0100
commitdfef82f273690130660acc4bf989d372c33e7528 (patch)
tree1cf682e11b3ebee221782e42e2aefa8aac337cf3 /gcc/rust/rust-session-manager.cc
parent9048f08f4e94594b837290ac26f3a5bbeb47f2c3 (diff)
downloadgcc-dfef82f273690130660acc4bf989d372c33e7528.zip
gcc-dfef82f273690130660acc4bf989d372c33e7528.tar.gz
gcc-dfef82f273690130660acc4bf989d372c33e7528.tar.bz2
gccrs: Resolve nested macro definition
We need to collect the early resolver's macros error to emit them at a later stage after further expansion in order to retrieve macros defined by other macro invocations. Register some mappings for macro invocations and macro definitions. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Collect error instead of emitting it. Also add invocation registration. * resolve/rust-early-name-resolver-2.0.h (std::function<void): Add type definition for collection. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Register macro rule definition in mappings. * rust-session-manager.cc (Session::expansion): Add macro resolve error collection. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r--gcc/rust/rust-session-manager.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 1c5d729..8911e7d 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -874,6 +874,7 @@ Session::expansion (AST::Crate &crate)
/* expand by calling cxtctxt object's monotonic_expander's expand_crate
* method. */
MacroExpander expander (crate, cfg, *this);
+ std::vector<Resolver2_0::ResolveError> macro_errors;
while (!fixed_point_reached && iterations < cfg.recursion_limit)
{
@@ -882,7 +883,11 @@ Session::expansion (AST::Crate &crate)
auto ctx = Resolver2_0::NameResolutionContext ();
if (flag_name_resolution_2_0)
- Resolver2_0::Early (ctx).go (crate);
+ {
+ Resolver2_0::Early early (ctx);
+ early.go (crate);
+ macro_errors = early.get_macro_resolve_errors ();
+ }
else
Resolver::EarlyNameResolver ().go (crate);
@@ -896,6 +901,10 @@ Session::expansion (AST::Crate &crate)
break;
}
+ // Fixed point reached: Emit unresolved macros error
+ for (auto &error : macro_errors)
+ error ();
+
if (iterations == cfg.recursion_limit)
{
auto &last_invoc = expander.get_last_invocation ();