summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test')
-rw-r--r--gcc/testsuite/gdc.test/compilable/betterCarray.d7
-rw-r--r--gcc/testsuite/gdc.test/compilable/extra-files/header1.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/imp17434a.d1
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/imp17434b.d6
-rw-r--r--gcc/testsuite/gdc.test/compilable/interpret3.d102
-rw-r--r--gcc/testsuite/gdc.test/compilable/json.d4
-rw-r--r--gcc/testsuite/gdc.test/compilable/mixintype2.d6
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_assign.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_not_reserved.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_opassign.d15
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_opopassign.d15
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_opunary.d18
-rw-r--r--gcc/testsuite/gdc.test/compilable/must_use_suppress.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/revert_dip1000.d7
-rw-r--r--gcc/testsuite/gdc.test/compilable/test17419.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/test17434.d11
-rw-r--r--gcc/testsuite/gdc.test/compilable/test17434a.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/test18216.d40
-rw-r--r--gcc/testsuite/gdc.test/compilable/test19097.d40
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22635.d13
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22988.d15
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22997.d14
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag11198.d12
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag14235.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag8101.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diagin.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail22202.d22
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail23036.d22
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail2656.d28
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail99.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail_scope.d30
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fix19059.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice10922.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice9540.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use_comma.d17
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use_opunary.d21
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use_reserved.d20
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use_template.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/must_use_union.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/retscope6.d48
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test11176.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test17284.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test19097.d64
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21008.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test22999.d27
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test23017.d20
-rw-r--r--gcc/testsuite/gdc.test/runnable/test20603.d31
-rw-r--r--gcc/testsuite/gdc.test/runnable/testscope.d16
-rw-r--r--gcc/testsuite/gdc.test/runnable/xtest46.d86
51 files changed, 822 insertions, 84 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/betterCarray.d b/gcc/testsuite/gdc.test/compilable/betterCarray.d
index 3e9a881c3d6..72dcc6b5ee3 100644
--- a/gcc/testsuite/gdc.test/compilable/betterCarray.d
+++ b/gcc/testsuite/gdc.test/compilable/betterCarray.d
@@ -26,3 +26,10 @@ void issue19234()
A[10] b;
b[] = a[];
}
+
+/**********************************************/
+// https://issues.dlang.org/show_bug.cgi?id=22922
+void issue22922()
+{
+ int[] x = [];
+}
diff --git a/gcc/testsuite/gdc.test/compilable/extra-files/header1.d b/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
index 3c2e90ab8ac..93f05a50c31 100644
--- a/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
+++ b/gcc/testsuite/gdc.test/compilable/extra-files/header1.d
@@ -607,3 +607,13 @@ T throwStuff(T)(T t)
if (false) test13x(1, throw new Exception(""), 2);
return t ? t : throw new Exception("Bad stuff happens!");
}
+
+class C12344
+{
+ abstract int c12344(int x) in(x > 0) out(result) {assert(result > 0);};
+}
+
+interface I12344
+{
+ int i12344(int x) in(x > 0) out(result) {assert(result > 0);};
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/imp17434a.d b/gcc/testsuite/gdc.test/compilable/imports/imp17434a.d
new file mode 100644
index 00000000000..5046cbb31ce
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/imp17434a.d
@@ -0,0 +1 @@
+module imp17434a.test1;
diff --git a/gcc/testsuite/gdc.test/compilable/imports/imp17434b.d b/gcc/testsuite/gdc.test/compilable/imports/imp17434b.d
new file mode 100644
index 00000000000..88c37ab488a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/imp17434b.d
@@ -0,0 +1,6 @@
+module imp.imports17434b;
+
+void testing()
+{
+ return;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/interpret3.d b/gcc/testsuite/gdc.test/compilable/interpret3.d
index ff85856b62e..2c9a84eddfb 100644
--- a/gcc/testsuite/gdc.test/compilable/interpret3.d
+++ b/gcc/testsuite/gdc.test/compilable/interpret3.d
@@ -2473,12 +2473,12 @@ static assert(checkPass("foobar") == 1);
struct Toq
{
- const(char)* m;
+ char* m;
}
Toq ptrRet(bool b)
{
- string x = "abc";
+ char[] x = "abc".dup;
return Toq(b ? x[0 .. 1].ptr : null);
}
@@ -7808,3 +7808,101 @@ int test9937()
}
static assert(test9937());
+
+/************************************************/
+// static array .tupleof
+
+struct SArrayTupleEquiv(T)
+{
+ T f1;
+ T f2;
+}
+
+// basic .tupleof invariants
+bool testSArrayTupleA()
+{
+ int[2] xs;
+ assert(xs.tupleof == TypeTuple!(0, 0));
+ assert(xs.tupleof == (cast(int[2])[0, 0]).tupleof);
+
+ xs.tupleof = TypeTuple!(1, 2);
+ assert(xs.tupleof == TypeTuple!(1, 2));
+
+ auto ys = SArrayTupleEquiv!int(1, 2);
+ assert(xs.tupleof == ys.tupleof);
+
+ return true;
+}
+static assert(testSArrayTupleA());
+
+// tuples with side effects
+bool testSArrayTupleB()
+{
+ // Counter records lifetime events in copies/dtors, as a cheap way to check that .tupleof for
+ // static arrays exhibit all the same side effects as an equivalent struct's .tupleof
+ int[int] copies;
+ int[int] dtors;
+ struct Counter
+ {
+ int id = -1;
+
+ this(this)
+ {
+ copies[id] = copies.get(id, 0) + 1;
+ }
+
+ ~this()
+ {
+ dtors[id] = dtors.get(id, 0) + 1;
+ }
+ }
+
+ void consume(Counter, Counter) {}
+ Counter[2] produce(int id1, int id2)
+ {
+ return [Counter(id1), Counter(id2)];
+ }
+
+ // first sample expected behavior from struct .tupleof
+ // braces create a subscope, shortening lifetimes
+ {
+ auto a = SArrayTupleEquiv!Counter(Counter(0), Counter(1));
+
+ typeof(a) b;
+ b.tupleof = a.tupleof;
+
+ Counter x, y;
+ TypeTuple!(x, y) = a.tupleof;
+
+ a.tupleof[0] = Counter(2);
+ a.tupleof[1] = Counter(3);
+ consume(a.tupleof);
+
+ a.tupleof = produce(4, 5).tupleof;
+ }
+ int[int][2] expected = [copies.dup, dtors.dup];
+ copies = null; // .clear is not CTFE friendly
+ dtors = null;
+
+ // the real test -- sample behavior of array .tupleof
+ {
+ Counter[2] a = [Counter(0), Counter(1)];
+
+ typeof(a) b;
+ b.tupleof = a.tupleof;
+
+ Counter x, y;
+ TypeTuple!(x, y) = a.tupleof;
+
+ a.tupleof[0] = Counter(2);
+ a.tupleof[1] = Counter(3);
+ consume(a.tupleof);
+
+ a.tupleof = produce(4, 5).tupleof;
+ }
+ assert(expected[0] == copies);
+ assert(expected[1] == dtors);
+
+ return true;
+}
+static assert(testSArrayTupleB());
diff --git a/gcc/testsuite/gdc.test/compilable/json.d b/gcc/testsuite/gdc.test/compilable/json.d
index 73d3101b835..f4d68e7dc8c 100644
--- a/gcc/testsuite/gdc.test/compilable/json.d
+++ b/gcc/testsuite/gdc.test/compilable/json.d
@@ -203,14 +203,14 @@ extern(C) int vlinakgeC;
extern(C++) __gshared int vlinkageCpp;
extern(Windows) int vlinkageWindows;
extern(Objective-C) int vlinkageObjc;
-
+extern(System) int vlinkageSystem;
extern int flinkageDefault();
extern(D) int flinkageD();
extern(C) int linakgeC();
extern(C++) int flinkageCpp();
extern(Windows) int flinkageWindows();
extern(Objective-C) int flinkageObjc();
-
+extern(System) int flinkageSystem();
mixin template test18211(int n)
{
static foreach (i; 0 .. n>10 ? 10 : n)
diff --git a/gcc/testsuite/gdc.test/compilable/mixintype2.d b/gcc/testsuite/gdc.test/compilable/mixintype2.d
index d160bd410ad..a61adc570fa 100644
--- a/gcc/testsuite/gdc.test/compilable/mixintype2.d
+++ b/gcc/testsuite/gdc.test/compilable/mixintype2.d
@@ -115,3 +115,9 @@ void test_statements_22356()
mixin("int") y22356, z22356;
static assert(is(typeof(y22356) == int) && is(typeof(z22356) == int));
}
+
+/**************************************************/
+// https://issues.dlang.org/show_bug.cgi?id=22969
+
+enum e = 0;
+alias a = mixin("e");
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_assign.d b/gcc/testsuite/gdc.test/compilable/must_use_assign.d
new file mode 100644
index 00000000000..bd1983a40e6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_assign.d
@@ -0,0 +1,9 @@
+import core.attribute;
+
+@mustuse struct S {}
+
+void test()
+{
+ S a, b;
+ a = b;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_not_reserved.d b/gcc/testsuite/gdc.test/compilable/must_use_not_reserved.d
new file mode 100644
index 00000000000..c6001198489
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_not_reserved.d
@@ -0,0 +1,5 @@
+import core.attribute;
+
+@mustuse int n;
+@mustuse alias A = int;
+@mustuse template tpl() {}
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_opassign.d b/gcc/testsuite/gdc.test/compilable/must_use_opassign.d
new file mode 100644
index 00000000000..8e877dd69b6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_opassign.d
@@ -0,0 +1,15 @@
+import core.attribute;
+
+@mustuse struct S
+{
+ ref S opAssign(S rhs) return
+ {
+ return this;
+ }
+}
+
+void test()
+{
+ S a, b;
+ a = b;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_opopassign.d b/gcc/testsuite/gdc.test/compilable/must_use_opopassign.d
new file mode 100644
index 00000000000..0176354ed1d
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_opopassign.d
@@ -0,0 +1,15 @@
+import core.attribute;
+
+@mustuse struct S
+{
+ ref S opOpAssign(string op)(S rhs) return
+ {
+ return this;
+ }
+}
+
+void test()
+{
+ S a, b;
+ a += b;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_opunary.d b/gcc/testsuite/gdc.test/compilable/must_use_opunary.d
new file mode 100644
index 00000000000..fc9650ebed5
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_opunary.d
@@ -0,0 +1,18 @@
+import core.attribute;
+
+@mustuse struct S
+{
+ ref S opUnary(string op)() return
+ {
+ return this;
+ }
+}
+
+void test()
+{
+ S s;
+ ++s;
+ --s;
+ s++;
+ s--;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/must_use_suppress.d b/gcc/testsuite/gdc.test/compilable/must_use_suppress.d
new file mode 100644
index 00000000000..63ad75c2928
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/must_use_suppress.d
@@ -0,0 +1,10 @@
+import core.attribute;
+
+@mustuse struct S {}
+
+S fun() { return S(); }
+
+void test()
+{
+ cast(void) fun();
+}
diff --git a/gcc/testsuite/gdc.test/compilable/revert_dip1000.d b/gcc/testsuite/gdc.test/compilable/revert_dip1000.d
new file mode 100644
index 00000000000..ad6a6d8aade
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/revert_dip1000.d
@@ -0,0 +1,7 @@
+/*
+REQUIRED_ARGS: -revert=dip1000
+TEST_OUTPUT:
+---
+---
+*/
+int* oops(scope int* p) @safe { return p; }
diff --git a/gcc/testsuite/gdc.test/compilable/test17419.d b/gcc/testsuite/gdc.test/compilable/test17419.d
index e34e7da5444..1a92a1c9112 100644
--- a/gcc/testsuite/gdc.test/compilable/test17419.d
+++ b/gcc/testsuite/gdc.test/compilable/test17419.d
@@ -17,10 +17,7 @@ static assert(__traits(getLinkage, food) == "D");
static assert(__traits(getLinkage, foocpp) == "C++");
static assert(__traits(getLinkage, foow) == "Windows");
static assert(__traits(getLinkage, fooobjc) == "Objective-C");
-version (Windows)
- static assert(__traits(getLinkage, foos) == "Windows");
-else
- static assert(__traits(getLinkage, foos) == "C");
+static assert(__traits(getLinkage, foos) == "System");
extern (C) int global;
static assert(__traits(getLinkage, global) == "C");
diff --git a/gcc/testsuite/gdc.test/compilable/test17434.d b/gcc/testsuite/gdc.test/compilable/test17434.d
new file mode 100644
index 00000000000..82bfa570b5f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test17434.d
@@ -0,0 +1,11 @@
+// https://issues.dlang.org/show_bug.cgi?id=17434
+
+// EXTRA_FILES: test17434a.d imports/imp17434a.d imports/imp17434b.d
+module test17434;
+
+import test17434a;
+
+void main()
+{
+ imports.imp17434b.testing();
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test17434a.d b/gcc/testsuite/gdc.test/compilable/test17434a.d
new file mode 100644
index 00000000000..c9175fe385b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test17434a.d
@@ -0,0 +1,5 @@
+// EXTRA_FILES: imports/imp17434a.d imports/imp17434b.d
+module test17434a;
+
+private import imports.imp17434a;
+public import imports.imp17434b;
diff --git a/gcc/testsuite/gdc.test/compilable/test18216.d b/gcc/testsuite/gdc.test/compilable/test18216.d
new file mode 100644
index 00000000000..43f5629a3c7
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test18216.d
@@ -0,0 +1,40 @@
+// https://issues.dlang.org/show_bug.cgi?id=18216
+
+struct Node
+{
+ mixin Type!();
+ Pointer left;
+}
+
+mixin template Type()
+{
+ alias Base = typeof(this);
+
+ static struct Proxy
+ {
+ struct Node
+ {
+ Base m_payload;
+ }
+ static immutable default_value = Base.init; // just remove this will work
+ }
+
+ alias pNode = shared(Proxy.Node)*;
+
+ static struct Pointer
+ {
+ Base* _ptr;
+ auto ptr()
+ {
+ return cast(pNode) _ptr;
+ }
+
+ void opAssign(ref Pointer other) {} // just remove this will work
+
+ alias getThis this; // just remove this will work
+ ref auto getThis() return
+ {
+ return ptr.m_payload;
+ }
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test19097.d b/gcc/testsuite/gdc.test/compilable/test19097.d
index 19e189caf5d..a6d30024881 100644
--- a/gcc/testsuite/gdc.test/compilable/test19097.d
+++ b/gcc/testsuite/gdc.test/compilable/test19097.d
@@ -21,3 +21,43 @@ void foo(scope int* pf)
betty(rf, pf);
boop(rf, pf);
}
+
+// https://issues.dlang.org/show_bug.cgi?id=22801
+struct Wrapper
+{
+ int* ptr;
+
+ this(return ref int var) @safe
+ {
+ this.ptr = &var;
+ }
+}
+
+void main() @safe
+{
+ int i;
+ auto w = Wrapper(i);
+ auto wt = WrapperT!()(i);
+}
+
+void assign(ref scope int* x, return ref int y) @safe
+{
+ x = &y;
+}
+
+// https://issues.dlang.org/show_bug.cgi?id=22967
+// inference of `return ref` when assigned to first parameter
+struct WrapperT()
+{
+ int* ptr;
+
+ this(ref int var) @safe
+ {
+ this.ptr = &var;
+ }
+
+ static void assignInferred(ref scope int* xi, ref int yi) @safe
+ {
+ xi = &yi;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22635.d b/gcc/testsuite/gdc.test/compilable/test22635.d
new file mode 100644
index 00000000000..c2abc837956
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22635.d
@@ -0,0 +1,13 @@
+// https://issues.dlang.org/show_bug.cgi?id=22635
+// opCast prevent calling destructor for const this
+
+struct Foo
+{
+ bool opCast(T : bool)() const { assert(0); }
+ ~this() {}
+}
+
+struct Bar
+{
+ const Foo foo;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22988.d b/gcc/testsuite/gdc.test/compilable/test22988.d
new file mode 100644
index 00000000000..6be3921e67b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22988.d
@@ -0,0 +1,15 @@
+// https://issues.dlang.org/show_bug.cgi?id=22988
+
+enum a1 = 0;
+enum b1 = a1 ? 1 << a1 - 1 : 0;
+
+enum l = 0;
+enum int[l] a2 = [];
+enum b2 = l ? a2[l - 1] : 0;
+
+enum a3 = 0 ? 1 << -1 : 0;
+
+enum int[0] a4 = [];
+enum b4 = 0 ? a4[0] : 0;
+
+enum b5 = false ? (1 << -1) : 0;
diff --git a/gcc/testsuite/gdc.test/compilable/test22997.d b/gcc/testsuite/gdc.test/compilable/test22997.d
new file mode 100644
index 00000000000..3cad527b4c2
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22997.d
@@ -0,0 +1,14 @@
+// https://issues.dlang.org/show_bug.cgi?id=22997
+
+struct Forward {}
+
+struct Foo
+{
+ this(ref typeof(this) rhs)
+ {
+ this(rhs, Forward.init);
+ }
+
+ this(ref typeof(this) rhs, Forward) {}
+ this(typeof(this) rhs, int i, double d, string s) {}
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag11198.d b/gcc/testsuite/gdc.test/fail_compilation/diag11198.d
index ebefa4dc6af..279d62a5496 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag11198.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag11198.d
@@ -1,8 +1,12 @@
/*
TEST_OUTPUT:
---
-fail_compilation/diag11198.d(11): Error: version conditions can only be declared at module scope
-fail_compilation/diag11198.d(12): Error: debug conditions can only be declared at module scope
+fail_compilation/diag11198.d(15): Error: version `blah` declaration must be at module level
+fail_compilation/diag11198.d(16): Error: debug `blah` declaration must be at module level
+fail_compilation/diag11198.d(17): Error: version `1` level declaration must be at module level
+fail_compilation/diag11198.d(18): Error: debug `2` level declaration must be at module level
+fail_compilation/diag11198.d(19): Error: identifier or integer expected, not `""`
+fail_compilation/diag11198.d(20): Error: identifier or integer expected, not `""`
---
*/
@@ -10,4 +14,8 @@ void main()
{
version = blah;
debug = blah;
+ version = 1;
+ debug = 2;
+ version = "";
+ debug = "";
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag14235.d b/gcc/testsuite/gdc.test/fail_compilation/diag14235.d
index 3c8a98e6e35..29261b4ea1c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag14235.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag14235.d
@@ -2,8 +2,8 @@
EXTRA_FILES: imports/a14235.d
TEST_OUTPUT:
---
-fail_compilation/diag14235.d(12): Error: template identifier `Undefined` is not a member of module `imports.a14235`
-fail_compilation/diag14235.d(13): Error: template identifier `Something` is not a member of module `imports.a14235`, did you mean struct `SomeThing(T...)`?
+fail_compilation/diag14235.d(12): Error: undefined identifier `Undefined` in module `imports.a14235`
+fail_compilation/diag14235.d(13): Error: undefined identifier `Something` in module `imports.a14235`, did you mean struct `SomeThing(T...)`?
fail_compilation/diag14235.d(14): Error: `imports.a14235.SomeClass` is not a template, it is a class
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
index 282665ff8d5..301472ca28a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag8101.d
@@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/diag8101.d(57): Error: function `diag8101.f_0(int)` is not callable using argument types `()`
-fail_compilation/diag8101.d(57): missing argument for parameter #1: `int`
+fail_compilation/diag8101.d(57): too few arguments, expected `1`, got `0`
fail_compilation/diag8101.d(58): Error: none of the overloads of `f_1` are callable using argument types `()`
fail_compilation/diag8101.d(33): Candidates are: `diag8101.f_1(int)`
fail_compilation/diag8101.d(34): `diag8101.f_1(int, int)`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d b/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d
index b46c562e87d..1279d7c2a2a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d
@@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/diag_funclit.d(103): Error: function literal `__lambda1(x, y, z)` is not callable using argument types `()`
-fail_compilation/diag_funclit.d(103): missing argument for parameter #1: `x`
+fail_compilation/diag_funclit.d(103): too few arguments, expected `3`, got `0`
fail_compilation/diag_funclit.d(106): Error: function literal `__lambda2(x, y, z)` is not callable using argument types `(int, string, int, int)`
fail_compilation/diag_funclit.d(106): too many arguments, expected `3`, got `4`
fail_compilation/diag_funclit.d(108): Error: function literal `__lambda3(x, y, string z = "Hello")` is not callable using argument types `(int, int, string, string)`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diagin.d b/gcc/testsuite/gdc.test/fail_compilation/diagin.d
index eb88a23151a..1418ced43a2 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diagin.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diagin.d
@@ -3,7 +3,7 @@ PERMUTE_ARGS: -preview=in
TEST_OUTPUT:
---
fail_compilation/diagin.d(14): Error: function `diagin.foo(in int)` is not callable using argument types `()`
-fail_compilation/diagin.d(14): missing argument for parameter #1: `in int`
+fail_compilation/diagin.d(14): too few arguments, expected `1`, got `0`
fail_compilation/diagin.d(16): Error: none of the overloads of template `diagin.foo1` are callable using argument types `!()(bool[])`
fail_compilation/diagin.d(20): Candidate is: `foo1(T)(in T v, string)`
---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22202.d b/gcc/testsuite/gdc.test/fail_compilation/fail22202.d
new file mode 100644
index 00000000000..167d3624879
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22202.d
@@ -0,0 +1,22 @@
+// https://issues.dlang.org/show_bug.cgi?id=22202
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail22202.d(21): Error: function `fail22202.fun(SystemCopy _param_0)` is not callable using argument types `(SystemCopy)`
+fail_compilation/fail22202.d(21): `inout ref inout(SystemCopy)(ref inout(SystemCopy) other)` copy constructor cannot be called from a `pure @safe nogc` context
+---
+*/
+
+struct SystemCopy
+{
+ this(ref inout SystemCopy other) inout {}
+}
+
+void fun(SystemCopy) @safe pure @nogc {}
+
+void main() @safe pure @nogc
+{
+ SystemCopy s;
+ fun(s);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23036.d b/gcc/testsuite/gdc.test/fail_compilation/fail23036.d
new file mode 100644
index 00000000000..8920586c67a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail23036.d
@@ -0,0 +1,22 @@
+// https://issues.dlang.org/show_bug.cgi?id=23036
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail23036.d(12): Error: `struct S` may not define both a rvalue constructor and a copy constructor
+fail_compilation/fail23036.d(15): rvalue constructor defined here
+fail_compilation/fail23036.d(14): copy constructor defined here
+---
+*/
+
+struct S
+{
+ this(ref S) {}
+ this(S, int a = 2) {}
+}
+
+void main()
+{
+ S a;
+ S b = a;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail2656.d b/gcc/testsuite/gdc.test/fail_compilation/fail2656.d
index ffd38de4502..520c1b14bfb 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail2656.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail2656.d
@@ -1,20 +1,20 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail2656.d(21): Error: octal literals `0123` are no longer supported, use `std.conv.octal!123` instead
-fail_compilation/fail2656.d(22): Error: octal literals `01000000000000000000000` are no longer supported, use `std.conv.octal!1000000000000000000000` instead
-fail_compilation/fail2656.d(23): Error: octal literals `0100000L` are no longer supported, use `std.conv.octal!100000L` instead
-fail_compilation/fail2656.d(24): Error: octal literals `01777777777777777777777u` are no longer supported, use `std.conv.octal!1777777777777777777777u` instead
-fail_compilation/fail2656.d(25): Error: octal literals `017777777777uL` are no longer supported, use `std.conv.octal!17777777777uL` instead
-fail_compilation/fail2656.d(26): Error: octal literals `0177777` are no longer supported, use `std.conv.octal!177777` instead
-fail_compilation/fail2656.d(27): Error: octal literals `020000000000L` are no longer supported, use `std.conv.octal!20000000000L` instead
-fail_compilation/fail2656.d(28): Error: octal literals `0200000u` are no longer supported, use `std.conv.octal!200000u` instead
-fail_compilation/fail2656.d(29): Error: octal literals `037777777777uL` are no longer supported, use `std.conv.octal!37777777777uL` instead
-fail_compilation/fail2656.d(30): Error: octal literals `040000000000` are no longer supported, use `std.conv.octal!40000000000` instead
-fail_compilation/fail2656.d(31): Error: octal literals `0777777777777777777777L` are no longer supported, use `std.conv.octal!777777777777777777777L` instead
-fail_compilation/fail2656.d(32): Error: octal literals `077777u` are no longer supported, use `std.conv.octal!77777u` instead
-fail_compilation/fail2656.d(33): Error: octal literals `077777uL` are no longer supported, use `std.conv.octal!77777uL` instead
-fail_compilation/fail2656.d(34): Error: octal literals `077777uL` are no longer supported, use `std.conv.octal!77777uL` instead
+fail_compilation/fail2656.d(21): Error: octal literals `0123` are no longer supported, use `std.conv.octal!"123"` instead
+fail_compilation/fail2656.d(22): Error: octal literals `01000000000000000000000` are no longer supported, use `std.conv.octal!"1000000000000000000000"` instead
+fail_compilation/fail2656.d(23): Error: octal literals `0100000L` are no longer supported, use `std.conv.octal!"100000L"` instead
+fail_compilation/fail2656.d(24): Error: octal literals `01777777777777777777777u` are no longer supported, use `std.conv.octal!"1777777777777777777777u"` instead
+fail_compilation/fail2656.d(25): Error: octal literals `017777777777uL` are no longer supported, use `std.conv.octal!"17777777777uL"` instead
+fail_compilation/fail2656.d(26): Error: octal literals `0177777` are no longer supported, use `std.conv.octal!"177777"` instead
+fail_compilation/fail2656.d(27): Error: octal literals `020000000000L` are no longer supported, use `std.conv.octal!"20000000000L"` instead
+fail_compilation/fail2656.d(28): Error: octal literals `0200000u` are no longer supported, use `std.conv.octal!"200000u"` instead
+fail_compilation/fail2656.d(29): Error: octal literals `037777777777uL` are no longer supported, use `std.conv.octal!"37777777777uL"` instead
+fail_compilation/fail2656.d(30): Error: octal literals `040000000000` are no longer supported, use `std.conv.octal!"40000000000"` instead
+fail_compilation/fail2656.d(31): Error: octal literals `0777777777777777777777L` are no longer supported, use `std.conv.octal!"777777777777777777777L"` instead
+fail_compilation/fail2656.d(32): Error: octal literals `077777u` are no longer supported, use `std.conv.octal!"77777u"` instead
+fail_compilation/fail2656.d(33): Error: octal literals `077777uL` are no longer supported, use `std.conv.octal!"77777uL"` instead
+fail_compilation/fail2656.d(34): Error: octal literals `077777uL` are no longer supported, use `std.conv.octal!"77777uL"` instead
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail99.d b/gcc/testsuite/gdc.test/fail_compilation/fail99.d
index c147b810ee6..e4cba9530bf 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail99.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail99.d
@@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/fail99.d(13): Error: delegate `dg(int)` is not callable using argument types `()`
-fail_compilation/fail99.d(13): missing argument for parameter #1: `int`
+fail_compilation/fail99.d(13): too few arguments, expected `1`, got `0`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d b/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
index 41a8c2d85e3..07c3766d490 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
@@ -2,6 +2,13 @@
REQUIRED_ARGS:
TEST_OUTPUT:
---
+fail_compilation/fail_scope.d(29): Deprecation: scope variable `da` may not be returned
+fail_compilation/fail_scope.d(31): Deprecation: scope variable `o` may not be returned
+fail_compilation/fail_scope.d(32): Deprecation: scope variable `dg` may not be returned
+fail_compilation/fail_scope.d(34): Deprecation: scope variable `da` may not be returned
+fail_compilation/fail_scope.d(36): Deprecation: scope variable `o` may not be returned
+fail_compilation/fail_scope.d(37): Deprecation: scope variable `dg` may not be returned
+fail_compilation/fail_scope.d(39): Deprecation: scope variable `p` may not be returned
fail_compilation/fail_scope.d(44): Error: returning `cast(char[])string` escapes a reference to local variable `string`
fail_compilation/fail_scope.d(62): Error: returning `s.bar()` escapes a reference to local variable `s`
fail_compilation/fail_scope.d(73): Error: `fail_scope.foo8` called with argument types `(int)` matches both:
@@ -15,26 +22,19 @@ fail_compilation/fail_scope.d(107): Deprecation: escaping reference to outer loc
fail_compilation/fail_scope.d(126): Error: returning `s.bar()` escapes a reference to local variable `s`
fail_compilation/fail_scope.d(136): Error: returning `foo16226(i)` escapes a reference to local variable `i`
---
-//fail_compilation/fail_scope.d(30): Error: scope variable `da` may not be returned
-//fail_compilation/fail_scope.d(32): Error: scope variable `o` may not be returned
-//fail_compilation/fail_scope.d(33): Error: scope variable `dg` may not be returned
-//fail_compilation/fail_scope.d(35): Error: scope variable `da` may not be returned
-//fail_compilation/fail_scope.d(37): Error: scope variable `o` may not be returned
-//fail_compilation/fail_scope.d(38): Error: scope variable `dg` may not be returned
-//fail_compilation/fail_scope.d(40): Error: scope variable `p` may not be returned
*/
alias int delegate() dg_t;
-int[] checkEscapeScope1(scope int[] da) { return da; }
-int[3] checkEscapeScope2(scope int[3] sa) { return sa; }
-Object checkEscapeScope3(scope Object o) { return o; }
-dg_t checkEscapeScope4(scope dg_t dg) { return dg; }
+int[] checkEscapeScope1(scope int[] da) @safe { return da; }
+int[3] checkEscapeScope2(scope int[3] sa) @safe { return sa; }
+Object checkEscapeScope3(scope Object o) @safe { return o; }
+dg_t checkEscapeScope4(scope dg_t dg) @safe { return dg; }
-int[] checkEscapeScope1() { scope int[] da = []; return da; }
-int[3] checkEscapeScope2() { scope int[3] sa = [1,2,3]; return sa; }
-Object checkEscapeScope3() { scope Object o = new Object; return o; } // same with fail7294.d
-dg_t checkEscapeScope4() { scope dg_t dg = () => 1; return dg; }
+int[] checkEscapeScope1() @safe { scope int[] da = []; return da; }
+int[3] checkEscapeScope2() @safe { scope int[3] sa = [1,2,3]; return sa; }
+Object checkEscapeScope3() @safe { scope Object o = new Object; return o; } // same with fail7294.d
+dg_t checkEscapeScope4() @safe { scope dg_t dg = () => 1; return dg; }
int* test(scope int* p) @safe { return p; }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fix19059.d b/gcc/testsuite/gdc.test/fail_compilation/fix19059.d
index 0be003a2f3b..b6bd9d33cf9 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fix19059.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fix19059.d
@@ -5,7 +5,7 @@ fail_compilation/fix19059.d(16): Error: octal digit expected, not `8`
fail_compilation/fix19059.d(16): Error: octal literals larger than 7 are no longer supported
fail_compilation/fix19059.d(17): Error: octal digit expected, not `9`
fail_compilation/fix19059.d(17): Error: octal literals larger than 7 are no longer supported
-fail_compilation/fix19059.d(18): Error: octal literals `010` are no longer supported, use `std.conv.octal!10` instead
+fail_compilation/fix19059.d(18): Error: octal literals `010` are no longer supported, use `std.conv.octal!"10"` instead
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d
index c227ee55eb4..f3a7a57a689 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d
@@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/ice10922.d(10): Error: function `ice10922.__lambda4(in uint n)` is not callable using argument types `()`
-fail_compilation/ice10922.d(10): missing argument for parameter #1: `in uint n`
+fail_compilation/ice10922.d(10): too few arguments, expected `1`, got `0`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice9540.d b/gcc/testsuite/gdc.test/fail_compilation/ice9540.d
index f95cb974c79..ce705078ac0 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice9540.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice9540.d
@@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/ice9540.d(35): Error: function `ice9540.A.test.AddFront!(this, f).AddFront.dg(int _param_0)` is not callable using argument types `()`
-fail_compilation/ice9540.d(35): missing argument for parameter #1: `int _param_0`
+fail_compilation/ice9540.d(35): too few arguments, expected `1`, got `0`
fail_compilation/ice9540.d(26): Error: template instance `ice9540.A.test.AddFront!(this, f)` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use.d b/gcc/testsuite/gdc.test/fail_compilation/must_use.d
new file mode 100644
index 00000000000..e3b5fedfd4d
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use.d
@@ -0,0 +1,16 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use.d(15): Error: ignored value of `@mustuse` type `must_use.S`; prepend a `cast(void)` if intentional
+---
++/
+import core.attribute;
+
+@mustuse struct S {}
+
+S fun() { return S(); }
+
+void test()
+{
+ fun();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use_comma.d b/gcc/testsuite/gdc.test/fail_compilation/must_use_comma.d
new file mode 100644
index 00000000000..4621ab5ec29
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use_comma.d
@@ -0,0 +1,17 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use_comma.d(16): Error: ignored value of `@mustuse` type `must_use_comma.S`; prepend a `cast(void)` if intentional
+---
++/
+import core.attribute;
+
+@mustuse struct S {}
+
+S fun() { return S(); }
+void sideEffect() {}
+
+void test()
+{
+ (fun(), sideEffect());
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use_opunary.d b/gcc/testsuite/gdc.test/fail_compilation/must_use_opunary.d
new file mode 100644
index 00000000000..59248a969c4
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use_opunary.d
@@ -0,0 +1,21 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use_opunary.d(20): Error: ignored value of `@mustuse` type `must_use_opunary.S`; prepend a `cast(void)` if intentional
+---
++/
+import core.attribute;
+
+@mustuse struct S
+{
+ ref S opUnary(string op)() return
+ {
+ return this;
+ }
+}
+
+void test()
+{
+ S s;
+ -s;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use_reserved.d b/gcc/testsuite/gdc.test/fail_compilation/must_use_reserved.d
new file mode 100644
index 00000000000..96edbd3cbe4
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use_reserved.d
@@ -0,0 +1,20 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use_reserved.d(14): Error: `@mustuse` on `class` types is reserved for future use
+fail_compilation/must_use_reserved.d(15): Error: `@mustuse` on `interface` types is reserved for future use
+fail_compilation/must_use_reserved.d(16): Error: `@mustuse` on `enum` types is reserved for future use
+fail_compilation/must_use_reserved.d(17): Error: `@mustuse` on functions is reserved for future use
+fail_compilation/must_use_reserved.d(19): Error: `@mustuse` on `class` types is reserved for future use
+fail_compilation/must_use_reserved.d(20): Error: template instance `must_use_reserved.CT!int` error instantiating
+---
++/
+import core.attribute;
+
+@mustuse class C {}
+@mustuse interface I {}
+@mustuse enum E { x }
+@mustuse int fun() { return 0; }
+
+@mustuse class CT(T) {}
+alias _ = CT!int;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use_template.d b/gcc/testsuite/gdc.test/fail_compilation/must_use_template.d
new file mode 100644
index 00000000000..eeaa774ea20
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use_template.d
@@ -0,0 +1,16 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use_template.d(15): Error: ignored value of `@mustuse` type `must_use_template.S!int`; prepend a `cast(void)` if intentional
+---
++/
+import core.attribute;
+
+@mustuse struct S(T) {}
+
+S!int fun() { return S!int(); }
+
+void test()
+{
+ fun();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/must_use_union.d b/gcc/testsuite/gdc.test/fail_compilation/must_use_union.d
new file mode 100644
index 00000000000..d42b324ee9b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/must_use_union.d
@@ -0,0 +1,16 @@
+/+
+TEST_OUTPUT:
+---
+fail_compilation/must_use_union.d(15): Error: ignored value of `@mustuse` type `must_use_union.U`; prepend a `cast(void)` if intentional
+---
++/
+import core.attribute;
+
+@mustuse union U {}
+
+U fun() { return U(); }
+
+void test()
+{
+ fun();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope6.d b/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
index 7e68bfc4702..6d5807b641a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/retscope6.d
@@ -201,8 +201,8 @@ void hmac(scope ubyte[] secret)
/* TEST_OUTPUT:
---
-fail_compilation/retscope6.d(12011): Error: reference to local variable `x` assigned to non-scope parameter `r` calling retscope6.escape_m_20150
-fail_compilation/retscope6.d(12022): Error: reference to local variable `x` assigned to non-scope parameter `r` calling retscope6.escape_c_20150
+fail_compilation/retscope6.d(12011): Error: returning `escape_m_20150(& x)` escapes a reference to local variable `x`
+fail_compilation/retscope6.d(12022): Error: returning `escape_c_20150(& x)` escapes a reference to local variable `x`
---
*/
@@ -210,23 +210,23 @@ fail_compilation/retscope6.d(12022): Error: reference to local variable `x` assi
// https://issues.dlang.org/show_bug.cgi?id=20150
-int* escape_m_20150(int* r) @safe pure
+int* escape_m_20150(int* r) @safe pure nothrow
{
return r;
}
-int* f_m_20150() @safe
+int* f_m_20150() @safe nothrow
{
int x = 42;
return escape_m_20150(&x);
}
-const(int)* escape_c_20150(const int* r) @safe pure
+const(int)* escape_c_20150(const int* r) @safe pure nothrow
{
return r;
}
-const(int)* f_c_20150() @safe
+const(int)* f_c_20150() @safe nothrow
{
int x = 42;
return escape_c_20150(&x);
@@ -251,3 +251,39 @@ void escape_throw_20150() @safe
immutable(char)[4] str;
f_throw(str[]);
}
+
+/* TEST_OUTPUT:
+---
+fail_compilation/retscope6.d(14019): Error: scope variable `scopePtr` assigned to non-scope parameter `x` calling retscope6.noInfer23021
+fail_compilation/retscope6.d(14022): Error: scope variable `scopePtr` may not be returned
+---
+*/
+
+#line 14000
+// https://issues.dlang.org/show_bug.cgi?id=23021
+
+ref int infer23021(ref int* x) @safe pure nothrow
+{
+ return *x;
+}
+
+ref int noInfer23021(ref int* x, const(int)** escapeHole = null) @safe pure nothrow
+{
+ *escapeHole = x;
+ return *x;
+}
+
+ref int escape23021() @safe
+{
+ scope int* scopePtr;
+ int* nonScopePtr = null;
+
+ // don't infer scope
+ cast(void) noInfer23021(scopePtr); // error
+
+ // ensure we infer return scope
+ return infer23021(scopePtr); // error
+
+ // ensure we do not infer return ref
+ return infer23021(nonScopePtr); // no error
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test11176.d b/gcc/testsuite/gdc.test/fail_compilation/test11176.d
index cf60b80fd7a..5ef7324ce8c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test11176.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test11176.d
@@ -12,6 +12,10 @@ fail_compilation/test11176.d(16): Error: `b.ptr` cannot be used in `@safe` code,
return *b.ptr;
}
-@safe ubyte oops(ubyte[3] b) {
+@safe ubyte oops(ubyte[0] b) {
+ return *b.ptr;
+}
+
+@safe ubyte cool(ubyte[1] b) {
return *b.ptr;
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test17284.d b/gcc/testsuite/gdc.test/fail_compilation/test17284.d
index 713be42e595..5bb3c2cc9f6 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test17284.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test17284.d
@@ -1,8 +1,8 @@
+/*
TEST_OUTPUT:
---
-fail_compilation/test17284.d(1): Error: no identifier for declarator `TEST_OUTPUT`
-fail_compilation/test17284.d(1): Error: declaration expected, not `:`
-fail_compilation/test17284.d(12): Error: unmatched closing brace
+fail_compilation/test17284.d(16): Error: field `U.c` cannot access pointers in `@safe` code that overlap other fields
+pure nothrow @safe void(U t)
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19097.d b/gcc/testsuite/gdc.test/fail_compilation/test19097.d
index 034813b5316..9c025a83ff0 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test19097.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test19097.d
@@ -1,12 +1,19 @@
/* REQUIRED_ARGS: -preview=dip1000
* TEST_OUTPUT:
---
-fail_compilation/test19097.d(37): Error: scope variable `s` may not be returned
-fail_compilation/test19097.d(66): Error: scope variable `z` assigned to `refPtr` with longer lifetime
-fail_compilation/test19097.d(97): Error: scope variable `s` may not be returned
+fail_compilation/test19097.d(44): Error: scope variable `s` may not be returned
+fail_compilation/test19097.d(48): Error: scope variable `s1` may not be returned
+fail_compilation/test19097.d(77): Error: scope variable `z` assigned to `refPtr` with longer lifetime
+fail_compilation/test19097.d(108): Error: scope variable `s4` may not be returned
+fail_compilation/test19097.d(126): Error: scope variable `s5c` may not be returned
+fail_compilation/test19097.d(130): Error: scope variable `s5m` may not be returned
+fail_compilation/test19097.d(147): Error: scope variable `s6c` may not be returned
+fail_compilation/test19097.d(151): Error: scope variable `s6m` may not be returned
---
*/
+// Test extended return-scope / return-ref semantics, e.g. assigning to `this` or the first parameter
+
// https://issues.dlang.org/show_bug.cgi?id=19097
@safe:
@@ -35,6 +42,10 @@ S thorin()
int i;
S s = S(&i); // should infer scope for s
return s; // so this should error
+
+ S s1;
+ s1.mem(&i);
+ return s1;
}
/************************/
@@ -93,6 +104,49 @@ struct S4
int* escape2()
{
int x;
- auto s = S4(0, &x);
- return s.p;
+ auto s4 = S4(0, &x);
+ return s4.p;
+}
+
+/************************/
+// https://issues.dlang.org/show_bug.cgi?id=22801
+struct S5
+{
+ int* a;
+ this(return ref int b) { a = &b; }
+
+ int* c;
+ void mem(return ref int d) scope { c = &d; }
+}
+
+S5 frerin()
+{
+ int i;
+ S5 s5c = S5(i); // should infer scope for s
+ return s5c; // so this should error
+
+ S5 s5m;
+ s5m.mem(i);
+ return s5m;
+}
+
+
+struct S6
+{
+ int** a;
+ this(return ref int* b) { a = &b; }
+
+ int** c;
+ void mem(return ref int* d) scope { c = &d; }
+}
+
+S6 dis()
+{
+ int* i = null;
+ S6 s6c = S6(i); // should infer scope for s
+ return s6c; // so this should error
+
+ S6 s6m;
+ s6m.mem(i);
+ return s6m;
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21008.d b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
index d5cf96a6c3a..998cf1752d0 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test21008.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
@@ -5,12 +5,12 @@ fail_compilation/test21008.d(110): Error: function `test21008.C.after` circular
fail_compilation/test21008.d(117): Error: need `this` for `toString` of type `string()`
fail_compilation/test21008.d(117): Error: need `this` for `toHash` of type `nothrow @trusted $?:32=uint|64=ulong$()`
fail_compilation/test21008.d(117): Error: function `object.Object.opCmp(Object o)` is not callable using argument types `()`
-fail_compilation/test21008.d(117): missing argument for parameter #1: `Object o`
+fail_compilation/test21008.d(117): too few arguments, expected `1`, got `0`
fail_compilation/test21008.d(117): Error: function `object.Object.opEquals(Object o)` is not callable using argument types `()`
-fail_compilation/test21008.d(117): missing argument for parameter #1: `Object o`
+fail_compilation/test21008.d(117): too few arguments, expected `1`, got `0`
fail_compilation/test21008.d(117): Error: `Monitor` has no effect
fail_compilation/test21008.d(117): Error: function `object.Object.factory(string classname)` is not callable using argument types `()`
-fail_compilation/test21008.d(117): missing argument for parameter #1: `string classname`
+fail_compilation/test21008.d(117): too few arguments, expected `1`, got `0`
fail_compilation/test21008.d(105): called from here: `handleMiddlewareAnnotation()`
fail_compilation/test21008.d(108): Error: class `test21008.C` no size because of forward reference
---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22999.d b/gcc/testsuite/gdc.test/fail_compilation/test22999.d
new file mode 100644
index 00000000000..99dfe70378b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22999.d
@@ -0,0 +1,27 @@
+/*
+REQUIRED_ARGS: -de
+TEST_OUTPUT:
+---
+fail_compilation/test22999.d(18): Deprecation: switch case fallthrough - use 'goto default;' if intended
+fail_compilation/test22999.d(25): Deprecation: switch case fallthrough - use 'goto case;' if intended
+---
+*/
+
+// no switch fallthrough error with multi-valued case
+// https://issues.dlang.org/show_bug.cgi?id=22999
+void main()
+{
+ int i;
+ switch (0)
+ {
+ case 0, 1: i = 20;
+ default: assert(0);
+ }
+
+ switch (0)
+ {
+ default:
+ case 0, 1: i = 20;
+ case 2, 3: i = 30;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23017.d b/gcc/testsuite/gdc.test/fail_compilation/test23017.d
new file mode 100644
index 00000000000..743789a6b52
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test23017.d
@@ -0,0 +1,20 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test23017.d(16): Error: class `test23017.CppChildA` with C++ linkage cannot inherit from class `DClass` with D linkage
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=23017
+// C++ class may not derive from D class
+extern(D) class DClass {}
+extern(C++) class CppClass
+{
+ void foo();
+}
+
+extern(C++) class CppChildA : DClass {} // error
+extern(C++) class CppChildB : CppClass {}
+
+extern(D) class DChildA : DClass {}
+extern(D) class DChildB : CppClass {} // automatically made extern(C++)
diff --git a/gcc/testsuite/gdc.test/runnable/test20603.d b/gcc/testsuite/gdc.test/runnable/test20603.d
new file mode 100644
index 00000000000..47fd3985555
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test20603.d
@@ -0,0 +1,31 @@
+// https://issues.dlang.org/show_bug.cgi?id=20603
+
+enum immutable(int)* x = new int(3);
+enum const(int)* y = new int(5);
+
+struct Base {
+ union {
+ int overlap;
+ immutable(Sub)* sub;
+ }
+
+ this(Sub) {
+ sub = new Sub;
+ }
+}
+
+struct Sub {
+ Base base;
+}
+
+immutable c0 = Base(Sub.init);
+
+void main()
+{
+ enum const(int)* z = new int(9);
+
+ assert(*x == 3);
+ assert(*y == 5);
+ assert(*z == 9);
+ assert(c0.sub.base.sub == null);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/testscope.d b/gcc/testsuite/gdc.test/runnable/testscope.d
index 32d66b58c76..0ca04df188d 100644
--- a/gcc/testsuite/gdc.test/runnable/testscope.d
+++ b/gcc/testsuite/gdc.test/runnable/testscope.d
@@ -242,22 +242,6 @@ void test7435() {
/********************************************/
-char[] dup12()(char[] a) // although inferred pure, don't infer a is 'return'
-{
- char[] res;
- foreach (ref e; a)
- {}
- return res;
-}
-
-char[] foo12()
-{
- char[10] buf;
- return dup12(buf);
-}
-
-/********************************************/
-
void test7049() @safe
{
int count = 0;
diff --git a/gcc/testsuite/gdc.test/runnable/xtest46.d b/gcc/testsuite/gdc.test/runnable/xtest46.d
index eeaa1dbe72d..8ae08ad2e47 100644
--- a/gcc/testsuite/gdc.test/runnable/xtest46.d
+++ b/gcc/testsuite/gdc.test/runnable/xtest46.d
@@ -3816,8 +3816,8 @@ void test153()
/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=3632
-
-void test154() {
+void test154()
+{
float f;
assert(f is float.init);
double d;
@@ -3832,6 +3832,87 @@ void test154() {
/***************************************************/
+__gshared int global3632 = 1;
+
+void test3632()
+{
+ int test(T)()
+ {
+ static struct W
+ {
+ T f;
+ this(T g) { if (__ctfe || global3632) f = g; }
+ }
+ auto nan = W(T.nan);
+ auto nan2 = W(T.nan);
+ auto init = W(T.init);
+ auto init2 = W(T.init);
+ auto zero = W(cast(T)0);
+ auto zero2 = W(cast(T)0);
+ auto nzero2 = W(-cast(T)0);
+
+ // Struct equality
+ assert(!(nan == nan2));
+ assert(!(nan == init2));
+ assert(!(init == init2));
+ assert( (zero == zero2));
+ assert( (zero == nzero2));
+
+ // Float equality
+ assert(!(nan.f == nan2.f));
+ assert(!(nan.f == init2.f));
+ assert(!(init.f == init2.f));
+ assert( (zero.f == zero2.f));
+ assert( (zero.f == nzero2.f));
+
+ // Struct identity
+ assert( (nan is nan2));
+ assert( (nan is init2));
+ assert( (init is init2));
+ assert( (zero is zero2));
+ assert(!(zero is nzero2));
+
+ // Float identity
+ assert( (nan.f is nan2.f));
+ assert( (nan.f is init2.f));
+ assert( (init.f is init2.f));
+ assert( (zero.f is zero2.f));
+ assert(!(zero.f is nzero2.f));
+
+ // Struct !identity
+ assert(!(nan !is nan2));
+ assert( (nan is init2));
+ assert(!(init !is init2));
+ assert(!(zero !is zero2));
+ assert( (zero !is nzero2));
+
+ // float !identity
+ assert(!(nan.f !is nan2.f));
+ assert( (nan.f is init2.f));
+ assert(!(init.f !is init2.f));
+ assert(!(zero.f !is zero2.f));
+ assert( (zero.f !is nzero2.f));
+
+ // .init identity
+ assert(W.init is W.init);
+
+ return 1;
+ }
+
+ auto rtF = test!float();
+ enum ctF = test!float();
+ auto rtD = test!double();
+ enum ctD = test!double();
+ auto rtR = test!real();
+ enum ctR = test!real();
+
+ assert(float.nan !is -float.nan);
+ assert(double.nan !is -double.nan);
+ assert(real.nan !is -real.nan);
+}
+
+/***************************************************/
+
void test6545()
{
static int[] func()
@@ -8142,6 +8223,7 @@ int main()
test155();
test156();
test658();
+ test3632();
test4258();
test4539();
test4963();