Skip to content

Commit

Permalink
Prevent error emission on resolver reentry
Browse files Browse the repository at this point in the history
The resolver was emitting an error when meeting the same symbol twice.
What is important here is the origin of the resolved symbol, we should
emit an error when the name is similar but the symbol isn't be not when
the resolver is simply meeting the exact same symbol.

gcc/rust/ChangeLog:

	* resolve/rust-toplevel-name-resolver-2.0.cc (insert_macros): Add
	constraint over the ast node id.
	(TopLevel::visit): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
  • Loading branch information
P-E-P authored and CohenArthur committed Nov 9, 2023
1 parent 3fa29c5 commit 6fd4d94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ insert_macros (std::vector<PROC_MACRO> &macros, NameResolutionContext &ctx)
{
auto res = ctx.macros.insert (macro.get_name (), macro.get_node_id ());

if (!res)
if (!res && res.error ().existing != macro.get_node_id ())
{
rust_error_at (UNKNOWN_LOCATION, ErrorCode::E0428,
"macro %qs defined multiple times",
Expand Down Expand Up @@ -167,7 +167,7 @@ TopLevel::visit (AST::MacroRulesDefinition &macro)
{
auto res = ctx.macros.insert_at_root (macro.get_rule_name (),
macro.get_node_id ());
if (!res)
if (!res && res.error ().existing != macro.get_node_id ())
{
// TODO: Factor this
rich_location rich_loc (line_table, macro.get_locus ());
Expand Down

0 comments on commit 6fd4d94

Please sign in to comment.