aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-08-15 17:51:03 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-08-15 21:35:10 +0200
commite206fecaac29f559f4990312b875604eb1ce3ef3 (patch)
treec207c52302fdcdea131f36001347991d46f0020e /gcc/testsuite/gdc.dg
parent250b1fa19d76b3e2f7a175b6b9ee6086fb548bfe (diff)
downloadgcc-e206fecaac29f559f4990312b875604eb1ce3ef3.zip
gcc-e206fecaac29f559f4990312b875604eb1ce3ef3.tar.gz
gcc-e206fecaac29f559f4990312b875604eb1ce3ef3.tar.bz2
d: Fix internal compiler error: Segmentation fault at gimple-expr.cc:88
Because complex types are deprecated in the language, the new way to expose native complex types is by defining an enum with a basetype of a library-defined struct that is implicitly treated as-if it is native. As casts are not implicitly added by the front-end when downcasting from enum to its underlying type, we must insert an explicit cast during the code generation pass. PR d/106623 gcc/d/ChangeLog: * d-codegen.cc (underlying_complex_expr): New function. (d_build_call): Handle passing native complex objects as the library-defined equivalent. * d-tree.h (underlying_complex_expr): Declare. * expr.cc (ExprVisitor::visit (DotVarExp *)): Call underlying_complex_expr instead of build_vconvert. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr106623.d: New test.
Diffstat (limited to 'gcc/testsuite/gdc.dg')
-rw-r--r--gcc/testsuite/gdc.dg/torture/pr106623.d28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.dg/torture/pr106623.d b/gcc/testsuite/gdc.dg/torture/pr106623.d
new file mode 100644
index 0000000..d782b23
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/torture/pr106623.d
@@ -0,0 +1,28 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106623
+// { dg-do compile }
+private struct _Complex(T) { T re; T im; }
+enum __c_complex_double : _Complex!double;
+
+pragma(inline, true)
+ulong hashOf()(scope const double val)
+{
+ return *cast(ulong*)&val;
+}
+
+pragma(inline, true)
+ulong hashOf()(scope const _Complex!double val, ulong seed = 0)
+{
+ return hashOf(val.re) + hashOf(val.im);
+}
+
+pragma(inline, true)
+ulong hashOf()(__c_complex_double val, ulong seed = 0)
+{
+ return hashOf(cast(_Complex!double) val, seed);
+}
+
+ulong test106623()
+{
+ __c_complex_double val;
+ return hashOf(val);
+}