Skip to content

Commit

Permalink
fix Issue 7983 - ICE with getMember on a unittest member
Browse files Browse the repository at this point in the history
Front-end should not switch its semantic process by global.params.useUnitTests.
  • Loading branch information
9rnsr committed Apr 25, 2012
1 parent 0d304bf commit 0e2c31f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
19 changes: 8 additions & 11 deletions src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -3948,17 +3948,14 @@ void UnitTestDeclaration::semantic(Scope *sc)
scope = NULL;
}

if (global.params.useUnitTests)
{
if (!type)
type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd);
Scope *sc2 = sc->push();
// It makes no sense for unit tests to be pure or nothrow.
sc2->stc &= ~(STCnothrow | STCpure);
sc2->linkage = LINKd;
FuncDeclaration::semantic(sc2);
sc2->pop();
}
if (!type)
type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd);
Scope *sc2 = sc->push();
// It makes no sense for unit tests to be pure or nothrow.
sc2->stc &= ~(STCnothrow | STCpure);
sc2->linkage = LINKd;
FuncDeclaration::semantic(sc2);
sc2->pop();

#if 0
// We're going to need ModuleInfo even if the unit tests are not
Expand Down
2 changes: 1 addition & 1 deletion src/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void TemplateDeclaration::semantic(Scope *sc)
}

#if DMDV2
if (/*global.params.useUnitTests &&*/ sc->module)
if (sc->module)
{
// Generate this function as it may be used
// when template is instantiated in other modules
Expand Down
18 changes: 18 additions & 0 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -5031,6 +5031,23 @@ class B1175 : A1175
I1 getI() { return new I2; }
}

/***************************************************/
// 7983

void test7983()
{
class A
{
unittest {}
}
A a;

foreach (name; __traits(allMembers, A))
{
static if (__traits(compiles, &__traits(getMember, a, name))) {}
}
}

/***************************************************/

int main()
Expand Down Expand Up @@ -5263,6 +5280,7 @@ int main()
test7871();
test7906();
test7907();
test7983();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 0e2c31f

Please sign in to comment.