]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR d/90602
authoribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:48:23 +0000 (07:48 +0000)
committeribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:48:23 +0000 (07:48 +0000)
d/dmd: Merge upstream dmd 420cce2a6

Fixes internal compiler error during CTFE.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272342 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/d/dmd/MERGE
gcc/d/dmd/dinterpret.c
gcc/testsuite/gdc.test/fail_compilation/fail19897.d [new file with mode: 0644]

index 6edc63a201420ea560ef1b335c905ae654d698b2..7456d604a91f79f8d7f83ed7db3eec4079da1750 100644 (file)
@@ -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.
index acca4e8097db7414038fa9873630ec9d9592f299..0749c7f487dd0d222ed25f5718fc9504d4c614cd 100644 (file)
@@ -6053,9 +6053,16 @@ public:
         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)
         {
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19897.d b/gcc/testsuite/gdc.test/fail_compilation/fail19897.d
new file mode 100644 (file)
index 0000000..8dd4e14
--- /dev/null
@@ -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;