Permalink
Browse files

Merge pull request #450 from donc/gagging

Properly fix bug 6661
  • Loading branch information...
WalterBright committed Oct 17, 2011
2 parents 59901d1 + 8ed5854 commit 7654a72e61b1ae322b9f55bbff97ea1c36db4622
Showing with 10 additions and 5 deletions.
  1. +9 −4 src/template.c
  2. +1 −1 test/compilable/compile1.d
View
@@ -5035,21 +5035,26 @@ void TemplateInstance::semantic3(Scope *sc)
sc = sc->push(this);
sc->tinst = this;
int oldgag = global.gag;
+ int olderrors = global.errors;
/* If this is a speculative instantiation, gag errors.
* Future optimisation: If the results are actually needed, errors
* would already be gagged, so we don't really need to run semantic
* on the members.
*/
- if (speculative && !global.gag)
- global.gag = 1;
+ if (speculative && !oldgag)
+ olderrors = global.startGagging();
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = members->tdata()[i];
s->semantic3(sc);
- if (global.gag && errors)
+ if (speculative && global.errors != olderrors)
break;
}
- global.gag = oldgag;
+ if (speculative && !oldgag)
+ { // If errors occurred, this instantiation failed
+ errors += global.errors - olderrors;
+ global.endGagging(olderrors);
+ }
sc = sc->pop();
sc->pop();
}
@@ -64,7 +64,7 @@ template bug6661(Q)
const Q blaz = 6;
}
-//static assert(is(typeof(bug6661!(int).blaz)));
+static assert(is(typeof(bug6661!(int).blaz)));
/**************************************************
6599 ICE(constfold.c) or segfault

0 comments on commit 7654a72

Please sign in to comment.