Commit e5338b04 by Iain Buclaw

re PR d/90761 (ICE in visit, at d/dmd/dcast.c:883)

	PR d/90761
d/dmd: Merge upstream dmd d912f4e49

Fixes segmentation fault in implicitConvTo::ImplicitConvTo::visit.

Reviewed-on: https://github.com/dlang/dmd/pull/10005

From-SVN: r272346
parent 88ad43b1
3be8a80bb0c4e01c436be970ac3555ceabb3caf8
d912f4e495412b67f0a2e3b07f645909cfee0212
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
......@@ -75,6 +75,7 @@ Expression *semantic(Expression *e, Scope *sc);
Expression *semanticY(DotIdExp *exp, Scope *sc, int flag);
Expression *semanticY(DotTemplateInstanceExp *exp, Scope *sc, int flag);
StringExp *semanticString(Scope *sc, Expression *exp, const char *s);
Initializer *semantic(Initializer *init, Scope *sc, Type *t, NeedInterpret needInterpret);
/****************************************
* Preprocess arguments to function.
......@@ -1226,6 +1227,23 @@ public:
exp->error("no constructor for %s", cd->toChars());
return setError();
}
// https://issues.dlang.org/show_bug.cgi?id=19941
// Run semantic on all field initializers to resolve any forward
// references. This is the same as done for structs in sd->fill().
for (ClassDeclaration *c = cd; c; c = c->baseClass)
{
for (size_t i = 0; i < c->fields.dim; i++)
{
VarDeclaration *v = c->fields[i];
if (v->inuse || v->_scope == NULL || v->_init == NULL ||
v->_init->isVoidInitializer())
continue;
v->inuse++;
v->_init = semantic(v->_init, v->_scope, v->type, INITinterpret);
v->inuse--;
}
}
}
}
else if (tb->ty == Tstruct)
......
// https://issues.dlang.org/show_bug.cgi?id=19941
/******************************************/
immutable i4 = 42;
const v4 = new C4;
class C4 { int f4 = i4; }
const v5 = new C5;
immutable i5 = 42;
class C5 { int f5 = i5; }
const v6 = new C6;
class C6 { int f6 = i6; }
immutable i6 = 42;
/******************************************/
immutable i10 = 42;
__gshared v10 = new C10;
class C10 { int f10 = i10; }
__gshared v11 = new C11;
immutable i11 = 42;
class C11 { int f11 = i11; }
__gshared v12 = new C12;
class C12 { int f12 = i12; }
immutable i12 = 42;
/******************************************/
immutable i13 = 42;
immutable v13 = new C13;
class C13 { int f13 = i13; }
immutable v14 = new C14;
immutable i14 = 42;
class C14 { int f14 = i14; }
immutable v15 = new C15;
class C15 { int f15 = i15; }
immutable i15 = 42;
/******************************************/
immutable i16 = 42;
shared v16 = new C16;
class C16 { int f16 = i16; }
shared v17 = new C17;
immutable i17 = 42;
class C17 { int f17 = i17; }
shared v18 = new C18;
class C18 { int f18 = i18; }
immutable i18 = 42;
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(8): Error: undefined identifier `dne`
---
*/
auto a = new Auto;
class Auto { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(17): Error: undefined identifier `dne`
---
*/
const c = new Const;
class Const { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(26): Error: undefined identifier `dne`
---
*/
enum e = new Enum;
class Enum { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(35): Error: undefined identifier `dne`
---
*/
__gshared g = new Gshared;
class Gshared { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(44): Error: undefined identifier `dne`
---
*/
immutable i = new Immutable;
class Immutable { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(53): Error: undefined identifier `dne`
---
*/
shared s = new Shared;
class Shared { int field = &dne; }
/*
TEST_OUTPUT:
---
fail_compilation/fail19941.d(62): Error: undefined identifier `dne`
---
*/
static t = new Static;
class Static { int field = &dne; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment