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/fail_pretty_errors.d18
6 files changed, 122 insertions, 8 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/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;
^
---