Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -5213,16 +5213,15 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
if (!e.type)
e.type = Type.tfloat64;
else if (!e.type.isImaginary || !sc.inCfile)
{
e.type = e.type.typeSemantic(e.loc, sc);
result = e;
return;
}

e.type = e.type.typeSemantic(e.loc, sc);
result = e;
return;

/* Convert to core.stdc.config.complex
* exempt C from this
*/
Type t = getComplexLibraryType(e.loc, sc, e.type.ty);
/*Type t = getComplexLibraryType(e.loc, sc, e.type.ty);
if (t.ty == Terror)
return setError();

Expand All @@ -5238,12 +5237,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor

/* Construct ts{re : 0.0, im : e}
*/
TypeStruct ts = t.isTypeStruct;
/*TypeStruct ts = t.isTypeStruct;
Expressions* elements = new Expressions(2);
(*elements)[0] = new RealExp(e.loc, CTFloat.zero, tf);
(*elements)[1] = new RealExp(e.loc, e.toImaginary(), tf);
Expression sle = new StructLiteralExp(e.loc, ts.sym, elements);
result = sle.expressionSemantic(sc);
result = sle.expressionSemantic(sc);*/
}

override void visit(ComplexExp e)
Expand Down
20 changes: 14 additions & 6 deletions compiler/src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2671,13 +2671,21 @@ Type typeSemantic(Type type, Loc loc, Scope* sc)

Type visitComplex(TypeBasic t)
{
if (!sc.inCfile)
return visitType(t);
return visitType(t);

auto tc = getComplexLibraryType(loc, sc, t.ty);
if (tc.ty == Terror)
return tc;
return tc.addMod(t.mod).merge();

//import std.stdio;
//writeln(t);
/* begins from here */
//if (!sc.inCfile) //
//return visitType(t); // both C and D gets here

//auto tc = getComplexLibraryType(loc, sc, t.ty);
//if (tc.ty == Terror)
// return tc;

//writeln("here", tc);
//return tc.addMod(t.mod).merge();
}

Type visitVector(TypeVector mtype)
Expand Down
13 changes: 13 additions & 0 deletions compiler/test/compilable/testcomplex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <complex.h>

void foo(_Complex double z)
{
return;
}


int main()
{
double z;
foo(z);
}
2 changes: 2 additions & 0 deletions druntime/test/importc_compare/src/importc_compare.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ immutable string[] growingTypes = [
// warnings for now.
immutable ErrorFilter[] knownProblems = [
ErrorFilter("core.stdc.config.c_long_double", "", "Windows", 32, ""),
ErrorFilter("core.stdc.config.c_complex_real", "", "Windows", 32, ""), // complex real is two long doubles so same for x86 Windows
ErrorFilter("core.stdc.config.__c_complex_real", "", "Windows", 32, ""),
ErrorFilter("core.stdc.fenv.fenv_t", "", "FreeBSD", 0, ""),
ErrorFilter("core.stdc.locale.lconv", "", "Apple", 0, "https://issues.dlang.org/show_bug.cgi?id=24652"),
ErrorFilter("core.stdc.locale.lconv", "", "FreeBSD", 0, "https://issues.dlang.org/show_bug.cgi?id=24652"),
Expand Down
Loading