diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index c1d5435e..db3cf1ae 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -13,6 +13,7 @@ #include "declaration.h" #include "dsymbol.h" #include "mtype.h" +#include "template.h" #include "gen/irstate.h" #include "gen/logger.h" @@ -315,9 +316,26 @@ std::vector IrTypeClass::buildVtblType(Type* first, Array* vtbl_arr IF_LOG Logger::println("Adding type of %s", fd->toPrettyChars()); - if (fd->type->nextOf() == NULL) { - // Return type of the virtual function has not been inferred. - // FIXME: is it a frontend bug? +#if DMDV2 + // If inferring return type and semantic3 has not been run, do it now. + // This pops up in some other places in the frontend as well, however + // it is probably a bug that it still occurs that late. + if (!fd->type->nextOf() && fd->inferRetType) + { + Logger::println("Running late semantic3 to infer return type."); + TemplateInstance *spec = fd->isSpeculative(); + int olderrs = global.errors; + fd->semantic3(fd->scope); + if (spec && global.errors != olderrs) + spec->errors = global.errors - olderrs; + } +#endif + + if (!fd->type->nextOf()) { + // Return type of the function has not been inferred. This seems to + // happen with virtual functions and is probably a frontend bug. + IF_LOG Logger::println("Broken function type, semanticRun: %d", + fd->semanticRun); types.push_back(getVoidPtrType()); continue; } diff --git a/tests/d2/dmd-testsuite b/tests/d2/dmd-testsuite index 8c08fe15..502d60e1 160000 --- a/tests/d2/dmd-testsuite +++ b/tests/d2/dmd-testsuite @@ -1 +1 @@ -Subproject commit 8c08fe15c3346e815e438ffbf05bb213a6d5efc4 +Subproject commit 502d60e1eafc463c28155fc3e219c941c0d3b132