[committed] d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)
Checks
Commit Message
Hi,
This patch fixes an ICE in the D front-end when importing symbols that
have multiple overloads.
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.
Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32,
committed to mainline, and backported to the release branches for
gcc-10, gcc-11, and gcc-12.
Regards,
Iain.
---
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.
---
gcc/d/decl.cc | 12 ++++++++++--
gcc/d/imports.cc | 14 ++++++++++++++
gcc/testsuite/gdc.dg/imports/pr108050/mod1.d | 2 ++
gcc/testsuite/gdc.dg/imports/pr108050/mod2.d | 2 ++
gcc/testsuite/gdc.dg/imports/pr108050/package.d | 2 ++
gcc/testsuite/gdc.dg/pr108050.d | 4 ++++
6 files changed, 34 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/package.d
create mode 100644 gcc/testsuite/gdc.dg/pr108050.d
@@ -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
@@ -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
{
new file mode 100644
@@ -0,0 +1,2 @@
+module imports.pr108050.mod1;
+string[] split() { return null; }
new file mode 100644
@@ -0,0 +1,2 @@
+module imports.pr108050.mod2;
+string[] split() { return null; }
new file mode 100644
@@ -0,0 +1,2 @@
+module imports.pr108050;
+public import imports.pr108050.mod1, imports.pr108050.mod2;
new file mode 100644
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-additional-sources "imports/pr108050/package.d imports/pr108050/mod1.d imports/pr108050/mod2.d" }
+// { dg-options "-g" }
+import imports.pr108050 : split;