aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-12-10 19:12:43 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-12-11 17:56:58 +0100
commitd9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f (patch)
treefb549ab2543c785e17320cba16f4f836bfacef61 /gcc/d
parentb045179973161115c7ea029b2788f5156fc55cda (diff)
downloadgcc-d9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f.zip
gcc-d9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f.tar.gz
gcc-d9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f.tar.bz2
d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)
The visitor for lowering IMPORTED_DECLs did not have an override for dealing with importing OverloadSet symbols. This has now been implemented in the code generator. PR d/108050 gcc/d/ChangeLog: * decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl returning a TREE_LIST. * imports.cc (ImportVisitor::visit (OverloadSet *)): New override. gcc/testsuite/ChangeLog: * gdc.dg/imports/pr108050/mod1.d: New. * gdc.dg/imports/pr108050/mod2.d: New. * gdc.dg/imports/pr108050/package.d: New. * gdc.dg/pr108050.d: New test.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/decl.cc12
-rw-r--r--gcc/d/imports.cc14
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index dcfca64..bed1632 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -198,8 +198,16 @@ public:
tree name = (alias != NULL)
? get_identifier (alias->toChars ()) : NULL_TREE;
- debug_hooks->imported_module_or_decl (decl, name, context,
- false, false);
+ if (TREE_CODE (decl) != TREE_LIST)
+ debug_hooks->imported_module_or_decl (decl, name, context,
+ false, false);
+ else
+ {
+ /* Overload sets return a list of imported decls. */
+ for (; decl != NULL_TREE; decl = TREE_CHAIN (decl))
+ debug_hooks->imported_module_or_decl (TREE_VALUE (decl), name,
+ context, false, false);
+ }
}
}
else
diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index 133d93d..2d331f4 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -160,6 +160,20 @@ public:
d->aliassym->accept (this);
}
+ /* Build IMPORTED_DECLs for all overloads in a set. */
+ void visit (OverloadSet *d) final override
+ {
+ vec<tree, va_gc> *tset = NULL;
+
+ vec_alloc (tset, d->a.length);
+
+ for (size_t i = 0; i < d->a.length; i++)
+ vec_safe_push (tset, build_import_decl (d->a[i]));
+
+ this->result_ = build_tree_list_vec (tset);
+ tset->truncate (0);
+ }
+
/* Function aliases are the same as alias symbols. */
void visit (FuncAliasDeclaration *d) final override
{