diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-02-27 20:46:18 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2023-03-03 01:25:32 +0100 |
commit | ce1cea3e22f58bbddde017f8a92e59bae8892339 (patch) | |
tree | 0e721708af289067b967cc6c8d00ab3817594478 /gcc/d/imports.cc | |
parent | 33a7811896a6c8e6fa71e385dbdf5013d833a116 (diff) | |
download | gcc-ce1cea3e22f58bbddde017f8a92e59bae8892339.zip gcc-ce1cea3e22f58bbddde017f8a92e59bae8892339.tar.gz gcc-ce1cea3e22f58bbddde017f8a92e59bae8892339.tar.bz2 |
d: Fix ICE on explicit immutable struct import [PR108877]
Const and immutable types are built as variants of the type they are
derived from, and TYPE_STUB_DECL is not set for these variants.
PR d/108877
gcc/d/ChangeLog:
* imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
make_import on TYPE_MAIN_VARIANT.
(ImportVisitor::visit (AggregateDeclaration *)): Likewise.
(ImportVisitor::visit (ClassDeclaration *)): Likewise.
gcc/testsuite/ChangeLog:
* gdc.dg/imports/pr108877a.d: New test.
* gdc.dg/pr108877.d: New test.
Diffstat (limited to 'gcc/d/imports.cc')
-rw-r--r-- | gcc/d/imports.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc index 3b46d1b..2efef4e 100644 --- a/gcc/d/imports.cc +++ b/gcc/d/imports.cc @@ -106,12 +106,16 @@ public: tree type = build_ctype (d->type); /* Not all kinds of D enums create a TYPE_DECL. */ if (TREE_CODE (type) == ENUMERAL_TYPE) - this->result_ = this->make_import (TYPE_STUB_DECL (type)); + { + type = TYPE_MAIN_VARIANT (type); + this->result_ = this->make_import (TYPE_STUB_DECL (type)); + } } void visit (AggregateDeclaration *d) final override { tree type = build_ctype (d->type); + type = TYPE_MAIN_VARIANT (type); this->result_ = this->make_import (TYPE_STUB_DECL (type)); } @@ -119,6 +123,7 @@ public: { /* Want the RECORD_TYPE, not POINTER_TYPE. */ tree type = TREE_TYPE (build_ctype (d->type)); + type = TYPE_MAIN_VARIANT (type); this->result_ = this->make_import (TYPE_STUB_DECL (type)); } |