aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-08-25 19:04:50 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-08-28 00:16:34 +0200
commitb7a586beae1027ea0c82411637920a5032d1dedf (patch)
tree4c41a84c4113e90cd0caaa7aa9925f4232dc22d5 /gcc/testsuite
parentcace77f4fb8df18c01dfdf9040cc944eedef1147 (diff)
downloadgcc-b7a586beae1027ea0c82411637920a5032d1dedf.zip
gcc-b7a586beae1027ea0c82411637920a5032d1dedf.tar.gz
gcc-b7a586beae1027ea0c82411637920a5032d1dedf.tar.bz2
d: Merge upstream dmd 817610b16d, phobos b578dfad9
D front-end changes: - Import latest bug fixes to mainline. Phobos changes: - Import latest bug fixes to mainline. - std.logger module has been moved out of experimental. - Removed std.experimental.typecons module. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 817610b16d. * d-ctfloat.cc (CTFloat::parse): Update for new front-end interface. * d-lang.cc (d_parse_file): Likewise. * expr.cc (ExprVisitor::visit (AssignExp *)): Remove handling of array assignments to non-trivial static and dynamic arrays. * runtime.def (ARRAYASSIGN): Remove. (ARRAYASSIGN_L): Remove. (ARRAYASSIGN_R): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 817610b16d. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/array/arrayassign.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos b578dfad9. * src/Makefile.am (PHOBOS_DSOURCES): Remove std/experimental/typecons.d. Add std/logger package. * src/Makefile.in: Regenerate.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gdc.test/compilable/aliasassign.d105
-rw-r--r--gcc/testsuite/gdc.test/compilable/scope_infer_array_assign.d28
-rw-r--r--gcc/testsuite/gdc.test/compilable/test21197.d25
-rw-r--r--gcc/testsuite/gdc.test/compilable/uda.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/aliasassign2.d33
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag23295.d40
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail10968.d29
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail14669.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice8795.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/imports/import15525.d3
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/issue12652.d24
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/retscope6.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/shared.d11
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test15525.d17
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test17423.d3
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test17764.d21
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test20245.d19
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test20809.d44
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test23073.d35
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/testsemi.d46
-rw-r--r--gcc/testsuite/gdc.test/runnable/test20365.d21
-rw-r--r--gcc/testsuite/gdc.test/runnable/test20809.d14
22 files changed, 500 insertions, 32 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/aliasassign.d b/gcc/testsuite/gdc.test/compilable/aliasassign.d
index a29836e..8643f5d 100644
--- a/gcc/testsuite/gdc.test/compilable/aliasassign.d
+++ b/gcc/testsuite/gdc.test/compilable/aliasassign.d
@@ -3,18 +3,18 @@ template AliasSeq(T...) { alias AliasSeq = T; }
template Unqual(T)
{
static if (is(T U == const U))
- alias Unqual = U;
+ alias Unqual = U;
else static if (is(T U == immutable U))
- alias Unqual = U;
+ alias Unqual = U;
else
- alias Unqual = T;
+ alias Unqual = T;
}
template staticMap(alias F, T...)
{
alias A = AliasSeq!();
static foreach (t; T)
- A = AliasSeq!(A, F!t); // what's tested
+ A = AliasSeq!(A, F!t); // what's tested
alias staticMap = A;
}
@@ -28,7 +28,7 @@ template reverse(T...)
{
alias A = AliasSeq!();
static foreach (t; T)
- A = AliasSeq!(t, A); // what's tested
+ A = AliasSeq!(t, A); // what's tested
alias reverse = A;
}
@@ -38,3 +38,98 @@ alias TK2 = reverse!(int, const uint, X2);
static assert(TK2[0] == 3);
static assert(is(TK2[1] == const(uint)));
static assert(is(TK2[2] == int));
+
+/**************************************************/
+
+template Tp(Args...)
+{
+ alias Tp = AliasSeq!(int, 1, "asd", Args);
+ static foreach (arg; Args)
+ {
+ Tp = AliasSeq!(4, Tp, "zxc", arg, Tp, 5, 4, int, Tp[0..2]);
+ }
+}
+
+void fun(){}
+
+alias a1 = Tp!(char[], fun, x => x);
+static assert(
+ __traits(isSame, a1, AliasSeq!(4, 4, 4, int, 1, "asd", char[], fun,
+ x => x, "zxc", char[], int, 1, "asd", char[], fun, x => x,
+ 5, 4, int, int, 1, "zxc", fun, 4, int, 1, "asd", char[],
+ fun, x => x, "zxc", char[], int, 1, "asd", char[], fun,
+ x => x, 5, 4, int, int, 1, 5, 4, int, 4, int, "zxc", x => x,
+ 4, 4, int, 1, "asd", char[], fun, x => x, "zxc", char[],
+ int, 1, "asd", char[], fun, x => x, 5, 4, int, int, 1,
+ "zxc", fun, 4, int, 1, "asd", char[], fun, x => x, "zxc",
+ char[], int, 1, "asd", char[], fun, x => x, 5, 4, int, int,
+ 1, 5, 4, int, 4, int, 5, 4, int, 4, 4)));
+
+template Tp2(Args...)
+{
+ alias Tp2 = () => 1;
+ static foreach (i; 0..Args.length)
+ Tp2 = AliasSeq!(Tp2, Args[i]);
+}
+
+const x = 8;
+static assert(
+ __traits(isSame, Tp2!(2, float, x), AliasSeq!(() => 1, 2, float, x)));
+
+
+enum F(int i) = i * i;
+
+template staticMap2(alias fun, args...)
+{
+ alias staticMap2 = AliasSeq!();
+ static foreach (i; 0 .. args.length)
+ staticMap2 = AliasSeq!(fun!(args[i]), staticMap2, fun!(args[i]));
+}
+
+enum a2 = staticMap2!(F, 0, 1, 2, 3, 4);
+
+struct Cmp(T...){}
+// isSame sucks
+static assert(is(Cmp!a2 == Cmp!(16, 9, 4, 1, 0, 0, 1, 4, 9, 16)));
+
+template Tp3()
+{
+ alias aa1 = int;
+ static foreach (t; AliasSeq!(float, char[]))
+ aa1 = AliasSeq!(aa1, t);
+ static assert(is(aa1 == AliasSeq!(int, float, char[])));
+
+ alias aa2 = AliasSeq!int;
+ static foreach (t; AliasSeq!(float, char[]))
+ aa2 = AliasSeq!(aa2, t);
+ static assert(is(aa2 == AliasSeq!(int, float, char[])));
+
+ alias aa3 = AliasSeq!int;
+ aa3 = AliasSeq!(float, char);
+ static assert(is(aa3 == AliasSeq!(float, char)));
+}
+alias a3 = Tp3!();
+
+template Tp4() // Uses slow path because overload
+{
+ alias AliasSeq(T...) = T;
+ alias AliasSeq(alias f, T...) = T;
+
+ alias aa4 = int;
+ aa4 = AliasSeq!(aa4, float);
+ static assert(is(aa4 == AliasSeq!(int, float)));
+
+}
+alias a4 = Tp4!();
+
+template Tp5() // same tp overloaded, still uses fast path
+{
+ alias AliasSeq2(T...) = T;
+ alias AliasSeq = AliasSeq2;
+ alias AliasSeq = AliasSeq2;
+
+ alias aa5 = int;
+ aa5 = AliasSeq!(aa5, float);
+ static assert(is(aa5 == AliasSeq!(int, float)));
+}
+alias a5 = Tp5!();
diff --git a/gcc/testsuite/gdc.test/compilable/scope_infer_array_assign.d b/gcc/testsuite/gdc.test/compilable/scope_infer_array_assign.d
new file mode 100644
index 0000000..8ef54a1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/scope_infer_array_assign.d
@@ -0,0 +1,28 @@
+// REQUIRED_ARGS: -preview=dip1000
+
+// Test that scope inference works even with non POD array assignment
+// This is tricky because it gets lowered to something like:
+// (S[] __assigntmp0 = e[]) , _d_arrayassign_l(this.e[], __assigntmp0) , this.e[];
+
+@safe:
+
+struct File
+{
+ void* f;
+ ~this() scope { }
+}
+
+struct Vector
+{
+ File[] e;
+
+ auto assign(File[] e)
+ {
+ this.e[] = e[]; // slice copy
+ }
+}
+
+void test(scope File[] arr, Vector v)
+{
+ v.assign(arr);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test21197.d b/gcc/testsuite/gdc.test/compilable/test21197.d
new file mode 100644
index 0000000..01ee66e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test21197.d
@@ -0,0 +1,25 @@
+/* REQUIRED_ARGS: -preview=dip1000
+ */
+// https://issues.dlang.org/show_bug.cgi?id=21197
+
+@safe void check2()
+{
+ int random;
+
+ S create1() return scope {
+ return S();
+ }
+
+ scope S gen1 = create1;
+
+ S create2() {
+ return S(&random);
+ }
+
+ scope S gen2 = create2;
+}
+
+struct S
+{
+ int* r;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/uda.d b/gcc/testsuite/gdc.test/compilable/uda.d
index ac66c2f..aa6277b 100644
--- a/gcc/testsuite/gdc.test/compilable/uda.d
+++ b/gcc/testsuite/gdc.test/compilable/uda.d
@@ -6,3 +6,9 @@ struct foo { }
@foo bar () { }
/************************************************/
+
+// https://issues.dlang.org/show_bug.cgi?id=23241
+
+alias feynman = int;
+enum get = __traits(getAttributes, feynman);
+static assert(get.length == 0);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/aliasassign2.d b/gcc/testsuite/gdc.test/fail_compilation/aliasassign2.d
new file mode 100644
index 0000000..dd421c9
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/aliasassign2.d
@@ -0,0 +1,33 @@
+/* TEST_OUTPUT:
+---
+fail_compilation/aliasassign2.d(16): Error: `alias aa1 = aa1;` cannot alias itself, use a qualified name to create an overload set
+fail_compilation/aliasassign2.d(19): Error: template instance `aliasassign2.Tp1!()` error instantiating
+fail_compilation/aliasassign2.d(24): Error: undefined identifier `unknown`
+fail_compilation/aliasassign2.d(26): Error: template instance `aliasassign2.Tp2!()` error instantiating
+fail_compilation/aliasassign2.d(31): Error: template instance `AliasSeqX!(aa3, 1)` template `AliasSeqX` is not defined, did you mean AliasSeq(T...)?
+fail_compilation/aliasassign2.d(33): Error: template instance `aliasassign2.Tp3!()` error instantiating
+---
+*/
+
+alias AliasSeq(T...) = T;
+
+template Tp1()
+{
+ alias aa1 = aa1;
+ aa1 = AliasSeq!(aa1, float);
+}
+alias a1 = Tp1!();
+
+template Tp2()
+{
+ alias aa2 = AliasSeq!();
+ aa2 = AliasSeq!(aa2, unknown);
+}
+alias a2 = Tp2!();
+
+template Tp3()
+{
+ alias aa3 = AliasSeq!();
+ aa3 = AliasSeqX!(aa3, 1);
+}
+alias a3 = Tp3!();
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag23295.d b/gcc/testsuite/gdc.test/fail_compilation/diag23295.d
new file mode 100644
index 0000000..a0bfe88
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag23295.d
@@ -0,0 +1,40 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/diag23295.d(21): Error: scope variable `x` assigned to non-scope parameter `y` calling `foo`
+fail_compilation/diag23295.d(32): which is assigned to non-scope parameter `z`
+fail_compilation/diag23295.d(34): which is not `scope` because of `f = & z`
+fail_compilation/diag23295.d(24): Error: scope variable `ex` assigned to non-scope parameter `e` calling `thro`
+fail_compilation/diag23295.d(39): which is not `scope` because of `throw e`
+---
+*/
+
+// explain why scope inference failed
+// https://issues.dlang.org/show_bug.cgi?id=23295
+
+@safe:
+
+void main()
+{
+ scope int* x;
+ foo(x, null);
+
+ scope Exception ex;
+ thro(ex);
+}
+
+auto foo(int* y, int** w)
+{
+ fooImpl(y, null);
+}
+
+auto fooImpl(int* z, int** w)
+{
+ auto f = &z;
+}
+
+auto thro(Exception e)
+{
+ throw e;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail10968.d b/gcc/testsuite/gdc.test/fail_compilation/fail10968.d
index d9f554a..e969b24 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail10968.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail10968.d
@@ -1,26 +1,27 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail10968.d(41): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(41): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
fail_compilation/fail10968.d(42): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
fail_compilation/fail10968.d(42): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
fail_compilation/fail10968.d(43): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
fail_compilation/fail10968.d(43): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
-fail_compilation/fail10968.d(46): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(46): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(44): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
+fail_compilation/fail10968.d(44): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(44): Error: `pure` function `fail10968.bar` cannot call impure function `core.internal.array.arrayassign._d_arrayassign_l!(SA[], SA)._d_arrayassign_l`
fail_compilation/fail10968.d(47): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
fail_compilation/fail10968.d(47): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
-fail_compilation/fail10968.d(47): Error: `pure` function `fail10968.bar` cannot call impure function `core.internal.array.construction._d_arraysetctor!(SA[], SA)._d_arraysetctor`
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
fail_compilation/fail10968.d(48): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
fail_compilation/fail10968.d(48): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
-fail_compilation/fail10968.d(29): `fail10968.SA.__postblit` is declared here
-fail_compilation/fail10968.d(48): Error: `pure` function `fail10968.bar` cannot call impure function `core.internal.array.construction._d_arrayctor!(SA[], SA)._d_arrayctor`
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(48): Error: `pure` function `fail10968.bar` cannot call impure function `core.internal.array.construction._d_arraysetctor!(SA[], SA)._d_arraysetctor`
+fail_compilation/fail10968.d(49): Error: `pure` function `fail10968.bar` cannot call impure function `fail10968.SA.__postblit`
+fail_compilation/fail10968.d(49): Error: `@safe` function `fail10968.bar` cannot call `@system` function `fail10968.SA.__postblit`
+fail_compilation/fail10968.d(30): `fail10968.SA.__postblit` is declared here
+fail_compilation/fail10968.d(49): Error: `pure` function `fail10968.bar` cannot call impure function `core.internal.array.construction._d_arrayctor!(SA[], SA)._d_arrayctor`
---
*/
@@ -51,12 +52,12 @@ void bar() pure @safe
/*
TEST_OUTPUT:
---
-fail_compilation/fail10968.d(74): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
fail_compilation/fail10968.d(75): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
fail_compilation/fail10968.d(76): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
-fail_compilation/fail10968.d(79): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
+fail_compilation/fail10968.d(77): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
fail_compilation/fail10968.d(80): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
fail_compilation/fail10968.d(81): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
+fail_compilation/fail10968.d(82): Error: struct `fail10968.SD` is not copyable because it has a disabled postblit
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail14669.d b/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
index be72663..5621ecc 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail14669.d
@@ -20,9 +20,9 @@ void test1()
/*
TEST_OUTPUT:
---
-fail_compilation/fail14669.d(29): Error: `auto` can only be used as part of `auto ref` for template function parameters
+fail_compilation/fail14669.d(29): Error: cannot explicitly instantiate template function with `auto ref` parameter
fail_compilation/fail14669.d(38): Error: template instance `fail14669.bar1!int` error instantiating
-fail_compilation/fail14669.d(30): Error: `auto` can only be used as part of `auto ref` for template function parameters
+fail_compilation/fail14669.d(30): Error: cannot explicitly instantiate template function with `auto ref` parameter
fail_compilation/fail14669.d(40): Error: template instance `fail14669.bar2!int` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice8795.d b/gcc/testsuite/gdc.test/fail_compilation/ice8795.d
index 5d7d6dd..a30a65b 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice8795.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice8795.d
@@ -3,7 +3,7 @@ TEST_OUTPUT:
---
fail_compilation/ice8795.d-mixin-14(14): Error: found `End of File` when expecting `(`
fail_compilation/ice8795.d-mixin-14(14): Error: expression expected, not `End of File`
-fail_compilation/ice8795.d-mixin-14(14): Error: found `End of File` when expecting `)`
+fail_compilation/ice8795.d-mixin-14(14): Error: missing closing `)` after `switch (0`
fail_compilation/ice8795.d-mixin-14(14): Error: found `End of File` instead of statement
fail_compilation/ice8795.d-mixin-15(15): Error: { } expected following `interface` declaration
fail_compilation/ice8795.d-mixin-15(15): Error: anonymous interfaces not allowed
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/import15525.d b/gcc/testsuite/gdc.test/fail_compilation/imports/import15525.d
new file mode 100644
index 0000000..9c05e7c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/imports/import15525.d
@@ -0,0 +1,3 @@
+module imports.import15525;
+
+template Tuple{ static if }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue12652.d b/gcc/testsuite/gdc.test/fail_compilation/issue12652.d
new file mode 100644
index 0000000..0ddd6b4
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/issue12652.d
@@ -0,0 +1,24 @@
+/*
+TEST_OUTPUT:
+----
+fail_compilation/issue12652.d(18): Error: static initializations of associative arrays is not allowed.
+fail_compilation/issue12652.d(18): associative arrays must be initialized at runtime: https://dlang.org/spec/hash-map.html#runtime_initialization
+---
+*/
+
+enum A
+{
+ x,
+ y,
+ z
+}
+
+struct S
+{
+ string[A] t = [A.x : "aaa", A.y : "bbb"];
+}
+
+void main ()
+{
+ S s;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope6.d b/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
index a8e5de5..95d5dbe 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
@@ -78,6 +78,7 @@ void foo() @safe
fail_compilation/retscope6.d(8016): Error: address of variable `i` assigned to `p` with longer lifetime
fail_compilation/retscope6.d(8031): Error: reference to local variable `i` assigned to non-scope parameter `p` calling `betty`
fail_compilation/retscope6.d(8031): Error: reference to local variable `j` assigned to non-scope parameter `q` calling `betty`
+fail_compilation/retscope6.d(8021): which is assigned to non-scope parameter `p`
fail_compilation/retscope6.d(8048): Error: reference to local variable `j` assigned to non-scope parameter `q` calling `archie`
---
*/
@@ -255,6 +256,7 @@ void escape_throw_20150() @safe
/* TEST_OUTPUT:
---
fail_compilation/retscope6.d(14019): Error: scope variable `scopePtr` assigned to non-scope parameter `x` calling `noInfer23021`
+fail_compilation/retscope6.d(14009): which is not `scope` because of `*escapeHole = cast(const(int)*)x`
fail_compilation/retscope6.d(14022): Error: scope variable `scopePtr` may not be returned
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/shared.d b/gcc/testsuite/gdc.test/fail_compilation/shared.d
index ab6f540..7d15b16 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/shared.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/shared.d
@@ -225,3 +225,14 @@ auto ref Object test_inference_4(const return shared ref Object a)
{
return a;
}
+
+// https://issues.dlang.org/show_bug.cgi?id=23226
+// Allow accessing non-shared `this`
+struct BitRange
+{
+ int bits;
+ void f()
+ {
+ this.bits++;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test15525.d b/gcc/testsuite/gdc.test/fail_compilation/test15525.d
new file mode 100644
index 0000000..cd35f30
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test15525.d
@@ -0,0 +1,17 @@
+// https://issues.dlang.org/show_bug.cgi?id=15525
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/imports/import15525.d(3): Error: parenthesized template parameter list expected following template identifier
+fail_compilation/imports/import15525.d(3): Error: (expression) expected following `static if`
+fail_compilation/imports/import15525.d(3): Error: declaration expected, not `}`
+fail_compilation/test15525.d(16): Error: template instance `Tuple!()` template `Tuple` is not defined
+---
+*/
+
+struct CrashMe
+{
+ import imports.import15525;
+ Tuple!() crash;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test17423.d b/gcc/testsuite/gdc.test/fail_compilation/test17423.d
index 3afb63b..faa9806 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test17423.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test17423.d
@@ -1,7 +1,8 @@
/* REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
-fail_compilation/test17423.d(26): Error: reference to local `this` assigned to non-scope parameter `dlg` calling `opApply`
+fail_compilation/test17423.d(27): Error: reference to local `this` assigned to non-scope parameter `dlg` calling `opApply`
+fail_compilation/test17423.d(16): which is not `scope` because of `this.myDlg = dlg`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test17764.d b/gcc/testsuite/gdc.test/fail_compilation/test17764.d
new file mode 100644
index 0000000..6ee988a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test17764.d
@@ -0,0 +1,21 @@
+/* REQUIRED_ARGS: -preview=dip1000
+ * TEST_OUTPUT:
+---
+fail_compilation/test17764.d(109): Error: scope variable `c` assigned to non-scope `global`
+---
+ */
+
+// https://issues.dlang.org/show_bug.cgi?id=17764
+
+#line 100
+
+int** global;
+
+struct S { int** str; }
+
+void f() @safe
+{
+ int* buf;
+ S[1] c = S(&buf);
+ global = c[0].str; /* This should be rejected. */
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test20245.d b/gcc/testsuite/gdc.test/fail_compilation/test20245.d
index 1713c9d..98caa03 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test20245.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test20245.d
@@ -2,15 +2,16 @@
REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
-fail_compilation/test20245.d(20): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling `escape`
-fail_compilation/test20245.d(21): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
-fail_compilation/test20245.d(22): Error: scope variable `a` may not be returned
-fail_compilation/test20245.d(26): Error: cannot take address of `scope` variable `x` since `scope` applies to first indirection only
-fail_compilation/test20245.d(32): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling `escape`
-fail_compilation/test20245.d(33): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
-fail_compilation/test20245.d(49): Error: reference to local variable `price` assigned to non-scope `this.minPrice`
-fail_compilation/test20245.d(68): Error: reference to local variable `this` assigned to non-scope parameter `msg` calling `this`
-fail_compilation/test20245.d(88): Error: reference to local variable `this` assigned to non-scope parameter `content` calling `listUp`
+fail_compilation/test20245.d(21): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling `escape`
+fail_compilation/test20245.d(22): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
+fail_compilation/test20245.d(23): Error: scope variable `a` may not be returned
+fail_compilation/test20245.d(27): Error: cannot take address of `scope` variable `x` since `scope` applies to first indirection only
+fail_compilation/test20245.d(33): Error: reference to local variable `x` assigned to non-scope parameter `ptr` calling `escape`
+fail_compilation/test20245.d(34): Error: copying `&x` into allocated memory escapes a reference to parameter `x`
+fail_compilation/test20245.d(50): Error: reference to local variable `price` assigned to non-scope `this.minPrice`
+fail_compilation/test20245.d(69): Error: reference to local variable `this` assigned to non-scope parameter `msg` calling `this`
+fail_compilation/test20245.d(89): Error: reference to local variable `this` assigned to non-scope parameter `content` calling `listUp`
+fail_compilation/test20245.d(82): which is not `scope` because of `charPtr = content`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test20809.d b/gcc/testsuite/gdc.test/fail_compilation/test20809.d
new file mode 100644
index 0000000..44728c5
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test20809.d
@@ -0,0 +1,44 @@
+/*
+REQUIRED_ARGS: -de
+TEST_OUTPUT:
+---
+fail_compilation/test20809.d(114): Deprecation: returning `this.a` escapes a reference to parameter `this`
+fail_compilation/test20809.d(112): perhaps annotate the function with `return`
+---
+ */
+
+// https://issues.dlang.org/show_bug.cgi?id=20809
+
+#line 100
+
+@safe:
+
+struct S
+{
+ @safe:
+ int a;
+ ~this()
+ {
+ a = 0;
+ }
+
+ ref int val()
+ {
+ return a;
+ }
+}
+
+S bar()
+{
+ return S(2);
+}
+
+int foo()
+{
+ return bar.val;
+}
+
+void test()
+{
+ assert(foo() == 2);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23073.d b/gcc/testsuite/gdc.test/fail_compilation/test23073.d
new file mode 100644
index 0000000..39106ba
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test23073.d
@@ -0,0 +1,35 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test23073.d(28): Error: scope variable `c` assigned to non-scope parameter `c` calling `assignNext`
+fail_compilation/test23073.d(22): which is not `scope` because of `c.next = c`
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=23073
+// scope inference from pure doesn't consider self-assignment
+
+@safe:
+
+class C
+{
+ C next;
+}
+
+void assignNext(C c) pure nothrow @nogc
+{
+ c.next = c;
+}
+
+C escape() @nogc
+{
+ scope C c = new C();
+ assignNext(c);
+ return c.next;
+}
+
+void main()
+{
+ C dangling = escape();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/testsemi.d b/gcc/testsuite/gdc.test/fail_compilation/testsemi.d
new file mode 100644
index 0000000..fc9bc65
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/testsemi.d
@@ -0,0 +1,46 @@
+/* TEST_OUTPUT:
+---
+fail_compilation/testsemi.d(102): Error: found `int` when expecting `;` following static assert
+fail_compilation/testsemi.d(102): Error: no identifier for declarator `x`
+fail_compilation/testsemi.d(109): Error: found `alias` when expecting `;` following alias reassignment
+fail_compilation/testsemi.d(112): Error: found `}` when expecting `;` following invariant
+fail_compilation/testsemi.d(117): Error: found `int` when expecting `;` following `alias Identifier this`
+fail_compilation/testsemi.d(117): Error: no identifier for declarator `x`
+fail_compilation/testsemi.d(123): Error: found `int` when expecting `;` following mixin
+fail_compilation/testsemi.d(129): Error: found `int` when expecting `;` following `import` Expression
+fail_compilation/testsemi.d(131): Error: `}` expected following members in `class` declaration at fail_compilation/testsemi.d(112)
+---
+ */
+
+#line 100
+
+static assert(1)
+int x;
+
+template map(alias F, Args...)
+{
+ alias A = AliasSeq!();
+ static foreach (Arg; Args)
+ A = AliasSeq!(A, F!Arg)
+ alias staticMap = A;
+}
+
+class C { invariant(3) }
+
+class D
+{
+ alias x this
+ int x;
+}
+
+void test1()
+{
+ mixin("int x;")
+ int y;
+}
+
+void test2()
+{
+ import(1)
+ int z;
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test20365.d b/gcc/testsuite/gdc.test/runnable/test20365.d
new file mode 100644
index 0000000..71865a5
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test20365.d
@@ -0,0 +1,21 @@
+// https://issues.dlang.org/show_bug.cgi?id=20365
+
+string result = "";
+
+struct S
+{
+ long[3] a;
+ this(ref typeof(this)) { result ~= "C"; }
+}
+
+void fun()
+{
+ S[4] a;
+ auto b = a;
+}
+
+void main()
+{
+ fun();
+ assert(result == "CCCC");
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test20809.d b/gcc/testsuite/gdc.test/runnable/test20809.d
new file mode 100644
index 0000000..6d6191e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test20809.d
@@ -0,0 +1,14 @@
+// https://issues.dlang.org/show_bug.cgi?id=20809
+
+
+@safe:
+struct S{
+ @safe:
+ int[8] a;
+ ~this(){ a[] = 0; }
+ ref val(){ return a; }
+}
+S bar(){ return S([2,2,2,2,2,2,2,2]); }
+int[8] foo(){ return bar.val; }
+
+void main(){ assert(foo() == [2,2,2,2,2,2,2,2]); } // error