aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-09-18 15:34:24 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-08-01 16:52:25 +0200
commit36ce08b23ed34ecda82a956998f39ce5afbcdec4 (patch)
tree581ae2ccfd02c9fc879bfb0951b9f22753094eb3 /gcc
parent97402694f71d96c89fac2ad2b859cbe6765e956a (diff)
downloadgcc-36ce08b23ed34ecda82a956998f39ce5afbcdec4.zip
gcc-36ce08b23ed34ecda82a956998f39ce5afbcdec4.tar.gz
gcc-36ce08b23ed34ecda82a956998f39ce5afbcdec4.tar.bz2
gccrs: Prevent error emission on resolver reentry
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 72c3560..3b1ccc1 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -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",
@@ -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 ());