diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index ac4fc4f39dbf..ed244fdc476d 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -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(); @@ -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) diff --git a/compiler/src/dmd/typesem.d b/compiler/src/dmd/typesem.d index 0c592077d0dc..72be65c10a57 100644 --- a/compiler/src/dmd/typesem.d +++ b/compiler/src/dmd/typesem.d @@ -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) diff --git a/compiler/test/compilable/testcomplex.c b/compiler/test/compilable/testcomplex.c new file mode 100644 index 000000000000..2be4cfd3e47d --- /dev/null +++ b/compiler/test/compilable/testcomplex.c @@ -0,0 +1,13 @@ +#include + +void foo(_Complex double z) +{ + return; +} + + +int main() +{ + double z; + foo(z); +} diff --git a/compiler/test/runnable/testc22259.c b/compiler/test/runnable/testc22259.c new file mode 100644 index 000000000000..c8201f0963c1 --- /dev/null +++ b/compiler/test/runnable/testc22259.c @@ -0,0 +1,22 @@ +// DISABLED: win32 win64 + +// https://github.com/dlang/dmd/issues/22259 + +#include +#include +#include + +void foo() +{ + _Complex double x = 1 + 1.0if; + assert(creal(x) == 1.000000); + assert(cimag(x) == 1.000000); + return; +} + + +int main() +{ + foo(); + return 0; +} diff --git a/druntime/test/importc_compare/src/importc_compare.d b/druntime/test/importc_compare/src/importc_compare.d index 54081a23f15a..bf3fd14172d8 100644 --- a/druntime/test/importc_compare/src/importc_compare.d +++ b/druntime/test/importc_compare/src/importc_compare.d @@ -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"),