From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id 3801D386F02C; Fri, 28 Aug 2020 19:54:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3801D386F02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598644480; bh=uRSv/FspLjNplNDBuieMZwXz5j39dcC3XLdCcGki7Rs=; h=From:To:Subject:Date:From; b=eE1it5zeCmFKcHeN1qDkdSvUJq4quKYbQMaPZM14OCyiEYtc8sEx96zr0wlKAYJUy 6TT9fhXiZqOrr2a+ezGXbw2eyHadMa6FSx65HLDGBGk6sgSN1XFEU8Fi+ocWE3N/rX 35v4RxTwWXhqB5Zef2jdRwC0iu6C1qHwTOS7w8D0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: William Schmidt To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/wschmidt/heads/builtins3)] d: Merge upstream dmd 1b5a53d01. X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/users/wschmidt/heads/builtins3 X-Git-Oldrev: 00cb0f5840795698557731c6e549a5ce99573223 X-Git-Newrev: 15717b4784053e59121a1e239d0081ca4d2c738a Message-Id: <20200828195440.3801D386F02C@sourceware.org> Date: Fri, 28 Aug 2020 19:54:40 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2020 19:54:40 -0000 https://gcc.gnu.org/g:15717b4784053e59121a1e239d0081ca4d2c738a commit 15717b4784053e59121a1e239d0081ca4d2c738a Author: Iain Buclaw Date: Thu Aug 20 18:18:40 2020 +0200 d: Merge upstream dmd 1b5a53d01. Fixes an ICE in setValue at dmd/dinterpret.c:7046 This was originally seen when running the testsuite for a 16-bit target, however, it could be reproduced on 32-bit using long[] as well. Reviewed-on: https://github.com/dlang/dmd/pull/11547 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 1b5a53d01. Diff: --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/ctfeexpr.c | 2 +- gcc/d/dmd/dinterpret.c | 9 ------ gcc/testsuite/gdc.test/compilable/interpret3.d | 38 +++++++++++++++++++++++ gcc/testsuite/gdc.test/fail_compilation/reg6769.d | 29 +++++++++++++++++ 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index daa3e565ff7..d0e5f442247 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -c2274e56a3220ea636c6199fd06cd54fcdf6bad9 +1b5a53d01c465109ce47edf49ace6143b69b118b The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/ctfeexpr.c b/gcc/d/dmd/ctfeexpr.c index 5230647e626..ee38033ac82 100644 --- a/gcc/d/dmd/ctfeexpr.c +++ b/gcc/d/dmd/ctfeexpr.c @@ -1913,7 +1913,7 @@ bool isCtfeValueValid(Expression *newval) // e1 should be a CTFE reference Expression *e1 = ((AddrExp *)newval)->e1; return tb->ty == Tpointer && - ((e1->op == TOKstructliteral && isCtfeValueValid(e1)) || + (((e1->op == TOKstructliteral || e1->op == TOKarrayliteral) && isCtfeValueValid(e1)) || (e1->op == TOKvar) || (e1->op == TOKdotvar && isCtfeReferenceValid(e1)) || (e1->op == TOKindex && isCtfeReferenceValid(e1)) || diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c index dd1105c03bd..74c5b40741f 100644 --- a/gcc/d/dmd/dinterpret.c +++ b/gcc/d/dmd/dinterpret.c @@ -1947,15 +1947,6 @@ public: Type *elemtype = ((TypeArray *)(val->type))->next; d_uns64 elemsize = elemtype->size(); - // It's OK to cast from fixed length to dynamic array, eg &int[3] to int[]* - if (val->type->ty == Tsarray && pointee->ty == Tarray && - elemsize == pointee->nextOf()->size()) - { - new(pue) AddrExp(e->loc, val, e->type); - result = pue->exp(); - return; - } - // It's OK to cast from fixed length to fixed length array, eg &int[n] to int[d]*. if (val->type->ty == Tsarray && pointee->ty == Tsarray && elemsize == pointee->nextOf()->size()) diff --git a/gcc/testsuite/gdc.test/compilable/interpret3.d b/gcc/testsuite/gdc.test/compilable/interpret3.d index 14d1a12c240..6e7304d742e 100644 --- a/gcc/testsuite/gdc.test/compilable/interpret3.d +++ b/gcc/testsuite/gdc.test/compilable/interpret3.d @@ -3235,6 +3235,44 @@ int ctfeSort6250() static assert(ctfeSort6250() == 57); +/**************************************************/ + +long[]* simple6250b(long[]* x) { return x; } + +void swap6250b(long[]* lhs, long[]* rhs) +{ + long[] kk = *lhs; + assert(simple6250b(lhs) == lhs); + lhs = simple6250b(lhs); + assert(kk[0] == 18); + assert((*lhs)[0] == 18); + assert((*rhs)[0] == 19); + *lhs = *rhs; + assert((*lhs)[0] == 19); + *rhs = kk; + assert(*rhs == kk); + assert(kk[0] == 18); + assert((*rhs)[0] == 18); +} + +long ctfeSort6250b() +{ + long[][2] x; + long[3] a = [17, 18, 19]; + x[0] = a[1 .. 2]; + x[1] = a[2 .. $]; + assert(x[0][0] == 18); + assert(x[0][1] == 19); + swap6250b(&x[0], &x[1]); + assert(x[0][0] == 19); + assert(x[1][0] == 18); + a[1] = 57; + assert(x[0][0] == 19); + return x[1][0]; +} + +static assert(ctfeSort6250b() == 57); + /************************************************** 6672 circular references in array **************************************************/ diff --git a/gcc/testsuite/gdc.test/fail_compilation/reg6769.d b/gcc/testsuite/gdc.test/fail_compilation/reg6769.d new file mode 100644 index 00000000000..b11fac925a0 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/reg6769.d @@ -0,0 +1,29 @@ +/* +TEST_OUTPUT +--- +fail_compilation/reg6769.d(14): Error: reinterpreting cast from `int[]` to `int[7]*` is not supported in CTFE +fail_compilation/reg6769.d(27): called from here: `reg6769a([0, 1, 2, 3, 4, 5, 6])` +fail_compilation/reg6769.d(27): while evaluating: `static assert(reg6769a([0, 1, 2, 3, 4, 5, 6]) == 1)` +fail_compilation/reg6769.d(20): Error: reinterpreting cast from `int[7]` to `int[]*` is not supported in CTFE +fail_compilation/reg6769.d(28): called from here: `reg6769b([0, 1, 2, 3, 4, 5, 6])` +fail_compilation/reg6769.d(28): while evaluating: `static assert(reg6769b([0, 1, 2, 3, 4, 5, 6]) == 1)` +--- +*/ +int reg6769a(int[] a) +{ + int[7]* b = cast(int[7]*)&a; + return (*b)[1]; +} + +int reg6769b(int[7] a) +{ + int[]* b = cast(int[]*)&a; + return (*b)[1]; +} + +void main() +{ + // Both should never succeed, run-time would raise a SEGV. + static assert(reg6769a([0,1,2,3,4,5,6]) == 1); + static assert(reg6769b([0,1,2,3,4,5,6]) == 1); +}