Commit 258ad811 by Iain Buclaw

d/dmd: Merge upstream dmd d7ed327ed

Fixes ICE when accessing empty array in CTFE.

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

From-SVN: r270294
parent 9eda9f92
5dd3eccc3b0758346f77bee3cdc3f6bd15de339b d7ed327edb0b01ad56e7e73e77b3401cd565675e
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository. merge done from the dlang/dmd repository.
...@@ -6272,11 +6272,14 @@ Expression *scrubReturnValue(Loc loc, Expression *e) ...@@ -6272,11 +6272,14 @@ Expression *scrubReturnValue(Loc loc, Expression *e)
/* Returns: true if e is void, /* Returns: true if e is void,
* or is an array literal or struct literal of void elements. * or is an array literal or struct literal of void elements.
*/ */
static bool isVoid(Expression *e) static bool isVoid(Expression *e, bool checkArray = false)
{ {
if (e->op == TOKvoid) if (e->op == TOKvoid)
return true; return true;
if (checkArray && e->type->ty != Tsarray)
return false;
if (e->op == TOKarrayliteral) if (e->op == TOKarrayliteral)
return isEntirelyVoid(((ArrayLiteralExp *)e)->elements); return isEntirelyVoid(((ArrayLiteralExp *)e)->elements);
...@@ -6314,7 +6317,7 @@ Expression *scrubArray(Loc loc, Expressions *elems, bool structlit) ...@@ -6314,7 +6317,7 @@ Expression *scrubArray(Loc loc, Expressions *elems, bool structlit)
// A struct .init may contain void members. // A struct .init may contain void members.
// Static array members are a weird special case (bug 10994). // Static array members are a weird special case (bug 10994).
if (structlit && isVoid(e)) if (structlit && isVoid(e, true))
{ {
e = NULL; e = NULL;
} }
......
struct S
{
int[] data;
}
immutable X = S([]);
enum len = X.data.length;
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