aboutsummaryrefslogtreecommitdiff
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/imports/test21098_phobos.d77
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/test21098b.d12
-rw-r--r--gcc/testsuite/gdc.test/compilable/test21098.d4
-rw-r--r--gcc/testsuite/gdc.test/compilable/test21153.d8
-rw-r--r--gcc/testsuite/gdc.test/compilable/test21179.d11
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail21045.d12
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail347.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail_pretty_errors.d18
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21247.d20
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21247b.d14
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ufcs.d36
-rw-r--r--gcc/testsuite/gdc.test/runnable/test21020.d11
12 files changed, 203 insertions, 24 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test21098_phobos.d b/gcc/testsuite/gdc.test/compilable/imports/test21098_phobos.d
new file mode 100644
index 0000000..29c77eb
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test21098_phobos.d
@@ -0,0 +1,77 @@
+struct Nullable(T)
+{
+ static struct DontCallDestructorT
+ {
+ T payload;
+ }
+
+ DontCallDestructorT _value;
+
+ string toString() const
+ {
+ Appender!string app;
+ formatValueImpl(app, _value);
+ return null;
+ }
+}
+
+
+
+struct Appender(A)
+{
+ InPlaceAppender!A impl;
+}
+
+struct InPlaceAppender(T)
+{
+ static void toStringImpl(const T[] data)
+ {
+ string app;
+ formatValue(app, data);
+ }
+}
+
+
+
+void formatValueImpl(Writer, T)(Writer, const(T)) {}
+
+void formatValueImpl(Writer, T)(Writer w, T obj)
+if (is(T == U[], U))
+{
+ formatValue(w, obj[0]);
+}
+
+enum HasToStringResult
+{
+ none,
+ bla
+}
+
+template hasToString(T)
+{
+ static if (is(typeof(
+ (T val) {
+ val.toString(s);
+ })))
+ enum hasToString = HasToStringResult.bla;
+ else
+ enum hasToString = HasToStringResult.none;
+}
+
+void formatValueImpl(Writer, T)(ref Writer w, T val)
+if (is(T == struct) || is(T == union))
+{
+ static if (hasToString!T)
+ int dummy;
+ formatElement(w, val.tupleof);
+}
+
+void formatElement(Writer, T)(Writer w, T val)
+{
+ formatValueImpl(w, val);
+}
+
+void formatValue(Writer, T)(Writer w, T val)
+{
+ formatValueImpl(w, val);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test21098b.d b/gcc/testsuite/gdc.test/compilable/imports/test21098b.d
new file mode 100644
index 0000000..74c9fa8
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test21098b.d
@@ -0,0 +1,12 @@
+import imports.test21098_phobos : Appender, Nullable;
+
+struct Type {
+ Nullable!(Type[]) templateArgs;
+}
+
+Type[] parseDeclarations() {
+ Appender!(Type[]) members;
+ return null;
+}
+
+enum ast = parseDeclarations();
diff --git a/gcc/testsuite/gdc.test/compilable/test21098.d b/gcc/testsuite/gdc.test/compilable/test21098.d
new file mode 100644
index 0000000..9b02b7b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test21098.d
@@ -0,0 +1,4 @@
+// https://github.com/dlang/dmd/issues/21098
+
+// EXTRA_FILES: imports/test21098b.d imports/test21098_phobos.d
+import imports.test21098b;
diff --git a/gcc/testsuite/gdc.test/compilable/test21153.d b/gcc/testsuite/gdc.test/compilable/test21153.d
new file mode 100644
index 0000000..cd92a31
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test21153.d
@@ -0,0 +1,8 @@
+// https://github.com/dlang/dmd/issues/21153
+alias AliasSeq(TList...) = TList;
+class DataClass;
+void reduce(DataClass[] r)
+{
+ alias Args = AliasSeq!(DataClass);
+ Args result = r[0];
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test21179.d b/gcc/testsuite/gdc.test/compilable/test21179.d
new file mode 100644
index 0000000..78bdffd
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test21179.d
@@ -0,0 +1,11 @@
+// https://github.com/dlang/dmd/issues/21179
+
+void bigEndianToNative(ubyte[2] a) {}
+
+void main()
+{
+ ubyte[] arr;
+ const ubyte[2] bytes;
+ bigEndianToNative(bytes);
+ auto b = cast(const ubyte[2][]) arr;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21045.d b/gcc/testsuite/gdc.test/fail_compilation/fail21045.d
new file mode 100644
index 0000000..c43eda3
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail21045.d
@@ -0,0 +1,12 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail21045.d(12): Error: unable to read module `__stdin`
+fail_compilation/fail21045.d(12): Expected '__stdin.d' or '__stdin/package.d' in one of the following import paths:
+import path[0] = fail_compilation
+import path[1] = $p:druntime/import$
+import path[2] = $p:phobos$
+---
+*/
+
+import __stdin;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail347.d b/gcc/testsuite/gdc.test/fail_compilation/fail347.d
index e495ba2..c56acf5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail347.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail347.d
@@ -5,10 +5,10 @@ TEST_OUTPUT:
fail_compilation/fail347.d(26): Error: undefined identifier `bbr`, did you mean variable `bar`?
fail_compilation/fail347.d(27): Error: no property `ofo` for type `S`, did you mean `fail347.S.foo`?
fail_compilation/fail347.d(29): Error: no property `fool` for `sp` of type `fail347.S*`
-fail_compilation/fail347.d(29): did you mean variable `foo`?
+fail_compilation/fail347.d(20): did you mean variable `foo`?
fail_compilation/fail347.d(30): Error: undefined identifier `strlenx`, did you mean function `strlen`?
fail_compilation/fail347.d(31): Error: no property `strlenx` for `"hello"` of type `string`
-fail_compilation/fail347.d(31): did you mean function `strlen`?
+fail_compilation/imports/fail347a.d(3): did you mean function `strlen`?
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail_pretty_errors.d b/gcc/testsuite/gdc.test/fail_compilation/fail_pretty_errors.d
index 2016a50..79242b1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail_pretty_errors.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail_pretty_errors.d
@@ -1,22 +1,24 @@
-/*
+/*
REQUIRED_ARGS: -verrors=context
TEST_OUTPUT:
---
-fail_compilation/fail_pretty_errors.d(27): Error: undefined identifier `a`
+fail_compilation/fail_pretty_errors.d(29): Error: undefined identifier `a`
a = 1;
^
-fail_compilation/fail_pretty_errors.d-mixin-32(32): Error: undefined identifier `b`
-fail_compilation/fail_pretty_errors.d(37): Error: cannot implicitly convert expression `5` of type `int` to `string`
+fail_compilation/fail_pretty_errors.d-mixin-34(34): Error: undefined identifier `b`
+b = 1;
+^
+fail_compilation/fail_pretty_errors.d(39): Error: cannot implicitly convert expression `5` of type `int` to `string`
string x = 5;
^
-fail_compilation/fail_pretty_errors.d(42): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating
+fail_compilation/fail_pretty_errors.d(44): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating
mixin mixinTemplate;
^
-fail_compilation/fail_pretty_errors.d(48): Error: invalid array operation `"" + ""` (possible missing [])
+fail_compilation/fail_pretty_errors.d(50): Error: invalid array operation `"" + ""` (possible missing [])
auto x = ""+"";
^
-fail_compilation/fail_pretty_errors.d(48): did you mean to concatenate (`"" ~ ""`) instead ?
-fail_compilation/fail_pretty_errors.d(51): Error: cannot implicitly convert expression `1111` of type `int` to `byte`
+fail_compilation/fail_pretty_errors.d(50): did you mean to concatenate (`"" ~ ""`) instead ?
+fail_compilation/fail_pretty_errors.d(53): Error: cannot implicitly convert expression `1111` of type `int` to `byte`
byte ɑ = 1111;
^
---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21247.d b/gcc/testsuite/gdc.test/fail_compilation/test21247.d
new file mode 100644
index 0000000..c3e4105
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21247.d
@@ -0,0 +1,20 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test21247.d(13): Error: anonymous union can only be a part of an aggregate, not function `hang_dmd`
+fail_compilation/test21247.d(17): Error: undefined identifier `u`
+fail_compilation/test21247.d(18): Error: undefined identifier `b`
+fail_compilation/test21247.d(20): called from here: `hang_dmd(0u)`
+---
+ */
+// https://github.com/dlang/dmd/issues/21247
+ubyte[4] hang_dmd(uint a)
+{
+ union {
+ uint u = void;
+ ubyte[4] b;
+ }
+ u = a;
+ return b;
+}
+enum T = hang_dmd(0);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21247b.d b/gcc/testsuite/gdc.test/fail_compilation/test21247b.d
new file mode 100644
index 0000000..ecd4603
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21247b.d
@@ -0,0 +1,14 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test21247b.d(10): Error: anonymous union can only be a part of an aggregate, not function `test21247`
+---
+ */
+// https://github.com/dlang/dmd/issues/21247
+void test21247()
+{
+ union {
+ uint u = void;
+ ubyte[4] b;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ufcs.d b/gcc/testsuite/gdc.test/fail_compilation/ufcs.d
index 3a92a69..87efbcf 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ufcs.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ufcs.d
@@ -1,23 +1,28 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ufcs.d(26): Error: no property `regularF` for `s` of type `S`
-fail_compilation/ufcs.d(26): the following error occured while looking for a UFCS match
-fail_compilation/ufcs.d(26): Error: function `regularF` is not callable using argument types `(S)`
-fail_compilation/ufcs.d(26): expected 0 argument(s), not 1
-fail_compilation/ufcs.d(31): `ufcs.regularF()` declared here
-fail_compilation/ufcs.d(27): Error: no property `templateF` for `s` of type `S`
-fail_compilation/ufcs.d(27): the following error occured while looking for a UFCS match
-fail_compilation/ufcs.d(27): Error: template `templateF` is not callable using argument types `!()(S)`
-fail_compilation/ufcs.d(32): Candidate is: `templateF()()`
-fail_compilation/ufcs.d(28): Error: no property `templateO` for `s` of type `S`
-fail_compilation/ufcs.d(28): the following error occured while looking for a UFCS match
-fail_compilation/ufcs.d(28): Error: none of the overloads of template `ufcs.templateO` are callable using argument types `!()(S)`
-fail_compilation/ufcs.d(34): Candidates are: `templateO()(int x)`
-fail_compilation/ufcs.d(35): `templateO()(float y)`
+fail_compilation/ufcs.d(31): Error: no property `regularF` for `s` of type `S`
+fail_compilation/ufcs.d(31): the following error occured while looking for a UFCS match
+fail_compilation/ufcs.d(31): Error: function `regularF` is not callable using argument types `(S)`
+fail_compilation/ufcs.d(31): expected 0 argument(s), not 1
+fail_compilation/ufcs.d(39): `ufcs.regularF()` declared here
+fail_compilation/ufcs.d(32): Error: no property `templateF` for `s` of type `S`
+fail_compilation/ufcs.d(32): the following error occured while looking for a UFCS match
+fail_compilation/ufcs.d(32): Error: template `templateF` is not callable using argument types `!()(S)`
+fail_compilation/ufcs.d(40): Candidate is: `templateF()()`
+fail_compilation/ufcs.d(33): Error: no property `templateO` for `s` of type `S`
+fail_compilation/ufcs.d(33): the following error occured while looking for a UFCS match
+fail_compilation/ufcs.d(33): Error: none of the overloads of template `ufcs.templateO` are callable using argument types `!()(S)`
+fail_compilation/ufcs.d(42): Candidates are: `templateO()(int x)`
+fail_compilation/ufcs.d(43): `templateO()(float y)`
+fail_compilation/ufcs.d(36): Error: no property `local` for `s` of type `ufcs.S`
+fail_compilation/ufcs.d(35): cannot call function `local` with UFCS because it is not declared at module scope
+fail_compilation/ufcs.d(26): struct `S` defined here
---
*/
+
+
struct S { }
void f()
@@ -26,6 +31,9 @@ void f()
s.regularF();
s.templateF();
s.templateO();
+
+ void local(S) {}
+ s.local();
}
void regularF();
diff --git a/gcc/testsuite/gdc.test/runnable/test21020.d b/gcc/testsuite/gdc.test/runnable/test21020.d
new file mode 100644
index 0000000..484db30
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test21020.d
@@ -0,0 +1,11 @@
+// https://github.com/dlang/dmd/issues/21020
+
+shared struct Queue {
+ int[int] map;
+}
+
+void main() {
+ auto queue = Queue();
+ (cast(int[int]) queue.map)[1] = 2;
+ assert(queue.map[1] == 2);
+}