]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Add test case for PR110959.
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 15 Aug 2023 15:10:45 +0000 (17:10 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 15 Aug 2023 15:16:21 +0000 (17:16 +0200)
This ICE is specific to the D front-end language version in GDC 12,
however a test has been added to mainline to catch the unlikely event of
a regression.

PR d/110959

gcc/testsuite/ChangeLog:

* gdc.dg/pr110959.d: New test.

gcc/testsuite/gdc.dg/pr110959.d [new file with mode: 0644]

diff --git a/gcc/testsuite/gdc.dg/pr110959.d b/gcc/testsuite/gdc.dg/pr110959.d
new file mode 100644 (file)
index 0000000..b1da90f
--- /dev/null
@@ -0,0 +1,32 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110959
+// { dg-do compile }
+class ArsdExceptionBase : object.Exception {
+    this(string operation, string file = __FILE__, size_t line = __LINE__, Throwable next = null) {
+        super(operation, file, line, next);
+    }
+}
+
+template ArsdException(alias Type, DataTuple...) {
+    static if(DataTuple.length)
+        alias Parent = ArsdException!(Type, DataTuple[0 .. $-1]);
+    else
+        alias Parent = ArsdExceptionBase;
+
+    class ArsdException : Parent {
+        DataTuple data;
+
+        this(DataTuple data, string file = __FILE__, size_t line = __LINE__) {
+            this.data = data;
+            static if(is(Parent == ArsdExceptionBase))
+                super(null, file, line);
+            else
+                super(data[0 .. $-1], file, line);
+        }
+
+        static opCall(R...)(R r, string file = __FILE__, size_t line = __LINE__) {
+            return new ArsdException!(Type, DataTuple, R)(r, file, line);
+        }
+    }
+}
+
+__gshared pr110959 = ArsdException!"Test"(4, "four");