Skip to content

Commit

Permalink
PR d/90602
Browse files Browse the repository at this point in the history
d/dmd: Merge upstream dmd 420cce2a6

Fixes internal compiler error during CTFE.

Reviewed-on: dlang/dmd#9997

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272342 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ibuclaw committed Jun 16, 2019
1 parent 28d90f3 commit 2f38d27
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gcc/d/dmd/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c74e624c9a0a9e7e39f96b2f005f86e123df56c9
420cce2a654f14b8de4a75cbb5d4203fce8d4e0f

The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
13 changes: 10 additions & 3 deletions gcc/d/dmd/dinterpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -6053,9 +6053,16 @@ class Interpreter : public Visitor
result = (*se->elements)[i];
if (!result)
{
e->error("Internal Compiler Error: null field %s", v->toChars());
result = CTFEExp::cantexp;
return;
// https://issues.dlang.org/show_bug.cgi?id=19897
// Zero-length fields don't have an initializer.
if (v->type->size() == 0)
result = voidInitLiteral(e->type, v).copy();
else
{
e->error("Internal Compiler Error: null field %s", v->toChars());
result = CTFEExp::cantexp;
return;
}
}
if (result->op == TOKvoid)
{
Expand Down
13 changes: 13 additions & 0 deletions gcc/testsuite/gdc.test/fail_compilation/fail19897.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// PERMUTE_ARGS:
/*
TEST_OUTPUT
---
fail_compilation/fail19897.d(10): Error: cannot implicitly convert expression `[]` of type `const(char[0])` to `const(char)`
---
*/
struct S
{
char[0] x;
}
const a = S('a');
const char c = a.x;

0 comments on commit 2f38d27

Please sign in to comment.