fix Issue 23778 - Code generator fails to handle __c_complex_real properly for Windows

This commit is contained in:
Walter Bright 2023-03-14 14:30:41 -07:00 committed by The Dlang Bot
parent 5a80cd7bc9
commit 5320bf2945
2 changed files with 33 additions and 2 deletions

View file

@ -1464,13 +1464,13 @@ tym_t totym(Type tx)
else if (id == Id.__c_ulong)
t = tb.ty == Tuns32 ? TYulong : TYullong;
else if (id == Id.__c_long_double)
t = TYdouble;
t = tb.size() == 8 ? TYdouble : TYldouble;
else if (id == Id.__c_complex_float)
t = TYcfloat;
else if (id == Id.__c_complex_double)
t = TYcdouble;
else if (id == Id.__c_complex_real)
t = TYcldouble;
t = tb.size() == 16 ? TYcdouble : TYcldouble;
else
t = totym(tb);
break;

View file

@ -0,0 +1,31 @@
// https://issues.dlang.org/show_bug.cgi?id=23778
enum __c_long_double : double;
alias __c_long_double c_long_double;
struct _Complex
{
c_long_double re;
c_long_double im;
}
version (all) // bug to test
{
enum __c_complex_real : _Complex;
alias c_complex_real = __c_complex_real;
}
else // works
enum c_complex_real : _Complex;
c_complex_real toNative2(real re, real im)
{
return c_complex_real(re, im);
}
void main()
{
c_complex_real n = toNative2(123, 456);
assert(123 == n.re && 456 == n.im);
}