From: Iain Buclaw Date: Tue, 15 Aug 2023 15:10:45 +0000 (+0200) Subject: d: Add test case for PR110959. X-Git-Tag: basepoints/gcc-15~6914 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4acce4c4e53ae93ab8e7dad2ca9099e45559a541;p=thirdparty%2Fgcc.git d: Add test case for PR110959. 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. --- diff --git a/gcc/testsuite/gdc.dg/pr110959.d b/gcc/testsuite/gdc.dg/pr110959.d new file mode 100644 index 000000000000..b1da90fad832 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr110959.d @@ -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");