diff mbox series

[committed] d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125]

Message ID 20240212161657.1200645-1-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: Fix internal compiler error: in make_import, at d/imports.cc:48 [PR113125] | expand

Commit Message

Iain Buclaw Feb. 12, 2024, 4:16 p.m. UTC
Hi,

This patch fixes an ICE triggered in the D front-end.

The cause of the ICE was that TYPE_DECLs were only being generated for
structs with members, not opaque structs.

	PR d/113125

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline.

Regards,
Iain.

---

gcc/d/ChangeLog:

	* types.cc (TypeVisitor::visit (TypeStruct *)): Generate TYPE_DECL and
	apply UDAs to opaque struct declarations.

gcc/testsuite/ChangeLog:

	* gdc.dg/imports/pr113125.d: New test.
	* gdc.dg/pr113125.d: New test.
---
 gcc/d/types.cc                          | 5 +++++
 gcc/testsuite/gdc.dg/imports/pr113125.d | 2 ++
 gcc/testsuite/gdc.dg/pr113125.d         | 4 ++++
 3 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr113125.d
 create mode 100644 gcc/testsuite/gdc.dg/pr113125.d
diff mbox series

Patch

diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index af9aad8a412..ed97aa39cc5 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -1230,6 +1230,11 @@  public:
 	apply_user_attributes (t->sym, t->ctype);
 	finish_aggregate_type (structsize, alignsize, t->ctype);
       }
+    else
+      {
+	build_type_decl (t->ctype, t->sym);
+	apply_user_attributes (t->sym, t->ctype);
+      }
 
     /* For structs with a user defined postblit, copy constructor, or a
        destructor, also set TREE_ADDRESSABLE on the type and all variants.
diff --git a/gcc/testsuite/gdc.dg/imports/pr113125.d b/gcc/testsuite/gdc.dg/imports/pr113125.d
new file mode 100644
index 00000000000..761e613b055
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr113125.d
@@ -0,0 +1,2 @@ 
+module imports.pr113125;
+struct S113125;
diff --git a/gcc/testsuite/gdc.dg/pr113125.d b/gcc/testsuite/gdc.dg/pr113125.d
new file mode 100644
index 00000000000..cb7300baa1a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr113125.d
@@ -0,0 +1,4 @@ 
+// { dg-do compile }
+// { dg-options "-I $srcdir/gdc.dg" }
+module pr113125;
+import imports.pr113125: S113125;