summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/fail_compilation')
-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
26 files changed, 357 insertions, 58 deletions
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++)