Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 11075 - ICE(struct.c) after gagged error in struct field initializer #2645

Merged
merged 1 commit into from Oct 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/class.c
Expand Up @@ -795,14 +795,12 @@ void ClassDeclaration::semantic(Scope *sc)
deferred->semantic3(sc);
}

#if 0
if (type->ty == Tclass && ((TypeClass *)type)->sym != this)
{
printf("this = %p %s\n", this, this->toChars());
printf("type = %d sym = %p\n", type->ty, ((TypeClass *)type)->sym);
error("failed semantic analysis");
this->errors = true;
type = Type::terror;
}
#endif
assert(type->ty != Tclass || ((TypeClass *)type)->sym == this);
}

void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
Expand Down Expand Up @@ -1480,14 +1478,12 @@ void InterfaceDeclaration::semantic(Scope *sc)
sc->pop();
//printf("-InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);

#if 0
if (type->ty == Tclass && ((TypeClass *)type)->sym != this)
{
printf("this = %p %s\n", this, this->toChars());
printf("type = %d sym = %p\n", type->ty, ((TypeClass *)type)->sym);
error("failed semantic analysis");
this->errors = true;
type = Type::terror;
}
#endif
assert(type->ty != Tclass || ((TypeClass *)type)->sym == this);
}


Expand Down
9 changes: 4 additions & 5 deletions src/struct.c
Expand Up @@ -858,6 +858,7 @@ void StructDeclaration::semantic(Scope *sc)
if (global.errors != errors)
{ // The type is no good.
type = Type::terror;
this->errors = true;
}

if (deferred && !global.gag)
Expand All @@ -866,14 +867,12 @@ void StructDeclaration::semantic(Scope *sc)
deferred->semantic3(sc);
}

#if 0
if (type->ty == Tstruct && ((TypeStruct *)type)->sym != this)
{
printf("this = %p %s\n", this, this->toChars());
printf("type = %d sym = %p\n", type->ty, ((TypeStruct *)type)->sym);
error("failed semantic analysis");
this->errors = true;
type = Type::terror;
}
#endif
assert(type->ty != Tstruct || ((TypeStruct *)type)->sym == this);
}

Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
Expand Down
22 changes: 22 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -6664,6 +6664,27 @@ void test7254()
assert(bar7254(0) == "1234");
}

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

struct S11075() { int x = undefined_expr; }

class C11075() { int x = undefined_expr; }

interface I11075() { enum int x = undefined_expr; }

void test11075()
{
static assert(!is(typeof(S11075!().x)));
static assert(!is(typeof(S11075!().x)));

static assert(!is(typeof(C11075!().x)));
static assert(!is(typeof(C11075!().x)));

static assert(!is(typeof(I11075!().x)));
static assert(!is(typeof(I11075!().x)));
}


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

int main()
Expand Down Expand Up @@ -6940,6 +6961,7 @@ int main()
test10539();
test10634();
test7254();
test11075();

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