Skip to content

Commit

Permalink
4269a Regression(2.031): invalid type accepted if evaluated while err…
Browse files Browse the repository at this point in the history
…ors are

gagged

Fixes the function, struct, class and alias test cases. Unlike the existing
catch-all in the glue layer, this patch gives proper front-end error messages.
Test cases 7, 11, 12, 13, and 15 are still not fixed.
  • Loading branch information
Don Clugston committed Feb 17, 2012
1 parent d41271c commit b1031a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,12 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
if (scope && !symtab)
{ Scope *sc = scope;
sc->mustsemantic++;
// If speculatively gagged, ungag now.
unsigned oldgag = global.gag;
if (global.isSpeculativeGagging())
global.gag = 0;
semantic(sc);
global.gag = oldgag;
sc->mustsemantic--;
}

Expand Down
4 changes: 2 additions & 2 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void AliasDeclaration::semantic(Scope *sc)
ScopeDsymbol::multiplyDefined(0, this, overnext);
this->inSemantic = 0;

if (errors != global.errors)
if (global.gag && errors != global.errors)
type = savedtype;
return;

Expand Down Expand Up @@ -538,7 +538,7 @@ void AliasDeclaration::semantic(Scope *sc)
assert(global.errors);
s = NULL;
}
if (errors != global.errors)
if (global.gag && errors != global.errors)
{
type = savedtype;
overnext = savedovernext;
Expand Down
6 changes: 6 additions & 0 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,13 @@ Expression *DsymbolExp::semantic(Scope *sc)
{ //printf("'%s' is a function\n", f->toChars());

if (!f->originalType && f->scope) // semantic not yet run
{
unsigned oldgag = global.gag;
if (global.isSpeculativeGagging() && !f->isSpeculative())
global.gag = 0;
f->semantic(f->scope);
global.gag = oldgag;
}

// if inferring return type, sematic3 needs to be run
if (f->inferRetType && f->scope && f->type && !f->type->nextOf())
Expand Down
5 changes: 5 additions & 0 deletions src/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,12 @@ void StructDeclaration::semantic(Scope *sc)
if (sizeok == 0 && s->isAliasDeclaration())
finalizeSize();
}
// Ungag errors when not speculative
unsigned oldgag = global.gag;
if (global.isSpeculativeGagging() && !isSpeculative())
global.gag = 0;
s->semantic(sc2);
global.gag = oldgag;
}

if (sizeok == 2)
Expand Down

0 comments on commit b1031a0

Please sign in to comment.