diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-08-20 18:18:40 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-08-21 01:08:08 +0200 |
commit | 15717b4784053e59121a1e239d0081ca4d2c738a (patch) | |
tree | b9f2a3d562acef103b6463a4d17495cc7f8bc538 /gcc/testsuite/gdc.test | |
parent | 00cb0f5840795698557731c6e549a5ce99573223 (diff) | |
download | gcc-15717b4784053e59121a1e239d0081ca4d2c738a.zip gcc-15717b4784053e59121a1e239d0081ca4d2c738a.tar.gz gcc-15717b4784053e59121a1e239d0081ca4d2c738a.tar.bz2 |
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.
Diffstat (limited to 'gcc/testsuite/gdc.test')
-rw-r--r-- | gcc/testsuite/gdc.test/compilable/interpret3.d | 38 | ||||
-rw-r--r-- | gcc/testsuite/gdc.test/fail_compilation/reg6769.d | 29 |
2 files changed, 67 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/interpret3.d b/gcc/testsuite/gdc.test/compilable/interpret3.d index 14d1a12..6e7304d 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 0000000..b11fac9 --- /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); +} |