diff mbox series

[committed] d: ICE in gimple_register_canonical_type_1, at lto/lto-common.c:430 (PR102094)

Message ID 20210829163126.2036025-1-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: ICE in gimple_register_canonical_type_1, at lto/lto-common.c:430 (PR102094) | expand

Commit Message

Iain Buclaw Aug. 29, 2021, 4:31 p.m. UTC
Hi,

User defined types have the TYPE_CXX_ODR_P flag set, but closure frames
did not.  This mismatch led to an ICE in the conflict detection for ODR
and interoperable non-ODR types.  As a given closure frame is tied
explicitly to a function, it already conforms to ODR.

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

Regards,
Iain

---
gcc/d/ChangeLog:

	PR d/102094
	* d-codegen.cc (build_frame_type): Set TYPE_CXX_ODR_P.

gcc/testsuite/ChangeLog:

	PR d/102094
	* gdc.dg/lto/pr102094_0.d: New test.
---
 gcc/d/d-codegen.cc                    |  1 +
 gcc/testsuite/gdc.dg/lto/pr102094_0.d | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/lto/pr102094_0.d
diff mbox series

Patch

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index fe2ad98e60a..ad20bd15403 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2563,6 +2563,7 @@  build_frame_type (tree ffi, FuncDeclaration *fd)
 
   TYPE_FIELDS (frame_rec_type) = fields;
   TYPE_READONLY (frame_rec_type) = 1;
+  TYPE_CXX_ODR_P (frame_rec_type) = 1;
   layout_type (frame_rec_type);
   d_keep (frame_rec_type);
 
diff --git a/gcc/testsuite/gdc.dg/lto/pr102094_0.d b/gcc/testsuite/gdc.dg/lto/pr102094_0.d
new file mode 100644
index 00000000000..f83631a1158
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/lto/pr102094_0.d
@@ -0,0 +1,18 @@ 
+// { dg-lto-do link }
+module pr102094_0;
+
+extern(C) int printf(char* s, ...);
+
+struct S102094
+{
+    int a;
+}
+
+void main()
+{
+    S102094 x;
+    void nested()
+    {
+        printf(cast(char*)0, x);
+    }
+}