mirror of
https://github.com/openRuyi-Project/gcc.git
synced 2026-09-06 14:01:37 +00:00
D front-end changes: - Import dmd v2.102.0-beta.1 - `static assert' now supports multiple message arguments. D runtime changes: - Import druntime v2.102.0-beta.1 - The default `Throwable.TraceInfo' generation now is `@nogc'. - `Object.factory' method has now been deprecated. Phobos changes: - Import phobos v2.102.0-beta.1 - Added float- and double-precision implementations for log function families in std.math. - `std.typecons.Unique' now calls `destroy` on struct types gcc/d/ChangeLog: * Make-lang.in (D_FRONTEND_OBJS): Add d/location.o. * d-lang.cc (d_init_options): Update for new front-end interface. (d_post_options): Call Loc::set after handling options. * dmd/MERGE: Merge upstream dmd 09faa4eacd. * dmd/VERSION: Bump version to v2.102.0-beta.1. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 09faa4eacd. * src/MERGE: Merge upstream phobos 13ef27a56. * testsuite/libphobos.exceptions/refcounted.d: Add test for chained reference counted exceptions. * testsuite/libphobos.shared/finalize.d: Add dg-warning for deprecated factory interfaces. * testsuite/libphobos.gc/issue22843.d: New test. gcc/testsuite/ChangeLog: * gdc.dg/simd2a.d: Update. * gdc.dg/simd2b.d: Update. * gdc.dg/simd2c.d: Update. * gdc.dg/simd2d.d: Update. * gdc.dg/simd2e.d: Update. * gdc.dg/simd2f.d: Update. * gdc.dg/simd2g.d: Update. * gdc.dg/simd2h.d: Update. * gdc.dg/simd2i.d: Update. * gdc.dg/simd2j.d: Update.
127 lines
2.3 KiB
D
127 lines
2.3 KiB
D
// { dg-options "-fpreview=dip1008" }
|
|
class E : Exception
|
|
{
|
|
static int instances;
|
|
this(string msg = "", Throwable nextInChain = null)
|
|
{
|
|
super(msg, nextInChain);
|
|
instances++;
|
|
}
|
|
|
|
~this()
|
|
{
|
|
instances--;
|
|
}
|
|
}
|
|
|
|
void main()
|
|
{
|
|
alias chain = Exception.chainTogether;
|
|
|
|
assert(chain(null, null) is null);
|
|
|
|
try
|
|
{
|
|
throw new E();
|
|
}
|
|
catch (E e)
|
|
{
|
|
assert(E.instances == 1);
|
|
assert(e.refcount == 2);
|
|
}
|
|
|
|
assert(E.instances == 0);
|
|
|
|
try
|
|
{
|
|
throw new E();
|
|
}
|
|
catch (E e)
|
|
{
|
|
assert(chain(null, e) is e);
|
|
assert(e.refcount == 2); // "Owned by e" + 1
|
|
}
|
|
|
|
assert(E.instances == 0);
|
|
|
|
try
|
|
{
|
|
throw new E();
|
|
}
|
|
catch (E e)
|
|
{
|
|
assert(chain(e, null) is e);
|
|
assert(e.refcount == 2); // "Owned by e" + 1
|
|
}
|
|
|
|
assert(E.instances == 0);
|
|
|
|
try
|
|
{
|
|
throw new E("first");
|
|
}
|
|
catch (E first)
|
|
{
|
|
try
|
|
{
|
|
throw new E("second");
|
|
}
|
|
catch (E second)
|
|
{
|
|
try
|
|
{
|
|
throw new E("third");
|
|
}
|
|
catch (E third)
|
|
{
|
|
assert(chain(first, second) is first);
|
|
assert(first.next is second);
|
|
assert(second.next is null);
|
|
|
|
assert(chain(first, third) is first);
|
|
assert(first.next is second);
|
|
assert(second.next is third);
|
|
assert(third.next is null);
|
|
|
|
assert(first.refcount == 2);
|
|
assert(second.refcount == 3);
|
|
assert(third.refcount == 3);
|
|
}
|
|
}
|
|
|
|
assert(E.instances == 3);
|
|
}
|
|
|
|
assert(E.instances == 0);
|
|
|
|
try
|
|
{
|
|
throw new E("first");
|
|
}
|
|
catch (E first)
|
|
{
|
|
assert(first.refcount == 2);
|
|
assert(E.instances == 1);
|
|
|
|
try
|
|
{
|
|
throw new E("second", first);
|
|
}
|
|
catch (E second)
|
|
{
|
|
assert(first.next is null);
|
|
assert(second.next is first);
|
|
|
|
assert(first.refcount == 3);
|
|
assert(second.refcount == 2);
|
|
|
|
assert(E.instances == 2);
|
|
}
|
|
|
|
assert(first.refcount == 2);
|
|
assert(E.instances == 1);
|
|
}
|
|
|
|
assert(E.instances == 0);
|
|
}
|