Fix error diagnosis for test fail91.

This commit is contained in:
Kai Nacke
2014-01-04 01:57:56 +01:00
parent acf1ed40b0
commit 27a9ede3fd
3 changed files with 12 additions and 2 deletions

View File

@@ -30,6 +30,11 @@
//////////////////////////////////////////////////////////////////////////////////////////
void DtoResolveStruct(StructDeclaration* sd)
{
DtoResolveStruct(sd, sd->loc);
}
void DtoResolveStruct(StructDeclaration* sd, Loc& callerLoc)
{
// Make sure to resolve each struct type exactly once.
if (sd->ir.resolved) return;
@@ -44,7 +49,7 @@ void DtoResolveStruct(StructDeclaration* sd)
// if it's a forward declaration, all bets are off. The type should be enough
if (sd->sizeok != SIZEOKdone)
{
error("struct %s.%s unknown size", sd->getModule()->toChars(), sd->toChars());
error(callerLoc, "struct %s.%s unknown size", sd->getModule()->toChars(), sd->toChars());
fatal();
}

View File

@@ -33,8 +33,13 @@ namespace llvm
* Sets up codegen metadata and emits global data (.init, etc.), if needed.
*
* Has no effect on already resolved struct declarations.
*
* callerLoc is the location of the expression which requires the struct type
* (only for better diagnosis)
*/
void DtoResolveStruct(StructDeclaration* sd);
void DtoResolveStruct(StructDeclaration* sd, Loc& callerLoc);
/// Returns a boolean=true if the two structs are equal.
llvm::Value* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs);

View File

@@ -2142,7 +2142,7 @@ DValue* NewExp::toElem(IRState* p)
}
else {
assert(ts->sym);
DtoResolveStruct(ts->sym);
DtoResolveStruct(ts->sym, loc);
DtoAggrCopy(mem, ts->sym->ir.irAggr->getInitSymbol());
}
if (ts->sym->isNested() && ts->sym->vthis)