Disable cross-module inlining of __invariant.

Resolves #1678.
This commit is contained in:
Johan Engelen 2016-08-13 17:31:13 +02:00
parent 807178d821
commit e6a18b2657
2 changed files with 32 additions and 0 deletions

View file

@ -123,6 +123,17 @@ bool defineAsExternallyAvailable(FuncDeclaration &fdecl) {
return false; return false;
} }
// Because the frontend names `__invariant*` functions differently depending
// on the compilation order, we cannot emit the `__invariant` wrapper that
// calls the `__invariant*` functions.
// This is a workaround, the frontend needs to be changed such that the
// __invariant* names no longer depend on semantic analysis order.
// See https://github.com/ldc-developers/ldc/issues/1678
if (fdecl.isInvariantDeclaration()) {
IF_LOG Logger::println("__invariant cannot be emitted.");
return false;
}
// TODO: Fix inlining functions from object.d. Currently errors because of // TODO: Fix inlining functions from object.d. Currently errors because of
// TypeInfo type-mismatch issue (TypeInfo classes get special treatment by the // TypeInfo type-mismatch issue (TypeInfo classes get special treatment by the
// compiler). To start working on it: comment-out this check and druntime will // compiler). To start working on it: comment-out this check and druntime will

View file

@ -0,0 +1,21 @@
// RUN: %ldc --enable-inlining -of=%t%exe %s
// https://github.com/ldc-developers/ldc/issues/1678
import std.datetime;
// Extra test that fail when a simple frontend change is tried that names __invariant using the line and column number.
class A {
mixin(genInv("666")); mixin(genInv("777"));
}
string genInv(string a) {
return "invariant() { }";
}
void main()
{
auto currentTime = Clock.currTime();
auto timeString = currentTime.toISOExtString();
auto restoredTime = SysTime.fromISOExtString(timeString);
}