diff --git a/dmd/expression.h b/dmd/expression.h index 664ce2b3..18e60ebf 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -233,6 +233,8 @@ struct ComplexExp : Expression #endif elem *toElem(IRState *irs); dt_t **toDt(dt_t **pdt); + // LLVMDC + virtual llvm::Constant *toConstElem(IRState *irs); }; struct IdentifierExp : Expression diff --git a/gen/toir.cpp b/gen/toir.cpp index 62a5c587..236ec408 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -318,6 +318,24 @@ llvm::Constant* NullExp::toConstElem(IRState* p) ////////////////////////////////////////////////////////////////////////////////////////// +DValue* ComplexExp::toElem(IRState* p) +{ + Logger::print("ComplexExp::toElem(): %s | %s\n", toChars(), type->toChars()); + LOG_SCOPE; + assert(0); +} + +////////////////////////////////////////////////////////////////////////////////////////// + +llvm::Constant* ComplexExp::toConstElem(IRState* p) +{ + Logger::print("ComplexExp::toConstElem(): %s | %s\n", toChars(), type->toChars()); + LOG_SCOPE; + assert(0); +} + +////////////////////////////////////////////////////////////////////////////////////////// + DValue* StringExp::toElem(IRState* p) { Logger::print("StringExp::toElem: %s | %s\n", toChars(), type->toChars()); @@ -1631,7 +1649,7 @@ DValue* DotVarExp::toElem(IRState* p) unsigned cc = (unsigned)-1; // virtual call - if (fdecl->isVirtual()) { + if (!fdecl->isFinal() && fdecl->isVirtual()) { assert(fdecl->vtblIndex > 0); assert(e1type->ty == Tclass); @@ -2858,7 +2876,7 @@ STUB(ScopeExp); STUB(TypeExp); //STUB(RealExp); -STUB(ComplexExp); +//STUB(ComplexExp); //STUB(StringExp); //STUB(IntegerExp); STUB(BoolExp); @@ -2885,6 +2903,7 @@ CONSTSTUB(Expression); //CONSTSTUB(IntegerExp); //CONSTSTUB(RealExp); //CONSTSTUB(NullExp); +//CONSTSTUB(ComplexExp); //CONSTSTUB(StringExp); //CONSTSTUB(VarExp); //CONSTSTUB(ArrayLiteralExp); diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 7261fc05..e1c38abd 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -69,9 +69,10 @@ const llvm::Type* DtoType(Type* t) // complex case Tcomplex32: + return DtoComplexType(llvm::Type::FloatTy); case Tcomplex64: case Tcomplex80: - assert(0 && "complex number types not yet implemented"); + return DtoComplexType(llvm::Type::DoubleTy); // pointers case Tpointer: { @@ -376,6 +377,16 @@ const llvm::StructType* DtoDelegateType(Type* t) ////////////////////////////////////////////////////////////////////////////////////////// +const llvm::StructType* DtoComplexType(const llvm::Type* base) +{ + std::vector types; + types.push_back(base); + types.push_back(base); + return llvm::StructType::get(types); +} + +////////////////////////////////////////////////////////////////////////////////////////// + static llvm::Function* LLVM_DeclareMemIntrinsic(const char* name, int bits, bool set=false) { assert(bits == 32 || bits == 64); diff --git a/gen/tollvm.h b/gen/tollvm.h index c839140c..9c0cbc8a 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -26,6 +26,8 @@ llvm::Value* DtoBoolean(llvm::Value* val); const llvm::Type* DtoSize_t(); +const llvm::StructType* DtoComplexType(const llvm::Type* base); + void DtoMain(); void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance); diff --git a/test/bug53.d b/test/bug53.d new file mode 100644 index 00000000..da6b05a1 --- /dev/null +++ b/test/bug53.d @@ -0,0 +1,6 @@ +module bug53; +class Foo { + final void bar() {} + void test() { bar(); } +} +void main() {} diff --git a/test/classinfo1.d b/test/classinfo1.d new file mode 100644 index 00000000..a8fdcd5e --- /dev/null +++ b/test/classinfo1.d @@ -0,0 +1,10 @@ +module classinfo1; + +class C +{ +} + +void main() +{ + auto ci = C.classinfo; +} diff --git a/test/complex1.d b/test/complex1.d new file mode 100644 index 00000000..80f66965 --- /dev/null +++ b/test/complex1.d @@ -0,0 +1,6 @@ +module complex1; + +void main() +{ + cfloat c1; +}