From patchwork Tue Nov 30 15:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 48297 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5B3F385C407 for ; Tue, 30 Nov 2021 15:15:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5B3F385C407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638285339; bh=vJsX7o0xvKdu2Zux4rGw7CG5McVPq8ZCenMpKq6Fibc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=S6IF3XAO1u0GFTjEhvkJ10l4a/9K6LsYNpAZpf/fGpLJkaPLHJlkGKAHiDI4xNimH P8Umai3TTFuzumi5i4EtHLetprmWu8jdon8GNR/blsvKcSu80cCC+tkBRzd2E/6CbL 9igID7fUDqquyF6D+K9oot74JA+53FN7Yy+PJBCQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id A122F385C40A for ; Tue, 30 Nov 2021 15:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A122F385C40A Received: from smtp102.mailbox.org (smtp102.mailbox.org [80.241.60.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4J3Qk12BzwzQjbk; Tue, 30 Nov 2021 16:14:33 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de To: gcc-patches@gcc.gnu.org Subject: [committed 18/19] testsuite: Update gdc testsuite to pass on latest version Date: Tue, 30 Nov 2021 16:14:24 +0100 Message-Id: <20211130151424.646687-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This updates the GDC testsuite parts to be compatible with the current language features/deprecations. The dejagnu gdc-utils helper has also been updated to handle the new options and directives added to the D2 testsuite tests. Bootstrapped, regression tested, and committed to mainline. Regards, Iain. --- gcc/testsuite/ChangeLog: * gdc.dg/Wcastresult2.d: Update test. * gdc.dg/asm1.d: Likewise. * gdc.dg/asm2.d: Likewise. * gdc.dg/asm3.d: Likewise. * gdc.dg/gdc282.d: Likewise. * gdc.dg/imports/gdc170.d: Likewise. * gdc.dg/intrinsics.d: Likewise. * gdc.dg/pr101672.d: Likewise. * gdc.dg/pr90650a.d: Likewise. * gdc.dg/pr90650b.d: Likewise. * gdc.dg/pr94777a.d: Likewise. * gdc.dg/pr95250.d: Likewise. * gdc.dg/pr96869.d: Likewise. * gdc.dg/pr98277.d: Likewise. * gdc.dg/pr98457.d: Likewise. * gdc.dg/simd1.d: Likewise. * gdc.dg/simd2a.d: Likewise. * gdc.dg/simd2b.d: Likewise. * gdc.dg/simd2c.d: Likewise. * gdc.dg/simd2d.d: Likewise. * gdc.dg/simd2e.d: Likewise. * gdc.dg/simd2f.d: Likewise. * gdc.dg/simd2g.d: Likewise. * gdc.dg/simd2h.d: Likewise. * gdc.dg/simd2i.d: Likewise. * gdc.dg/simd2j.d: Likewise. * gdc.dg/simd7951.d: Likewise. * gdc.dg/torture/gdc309.d: Likewise. * gdc.dg/torture/pr94424.d: Likewise. * gdc.dg/torture/pr94777b.d: Likewise. * lib/gdc-utils.exp (gdc-convert-args): Handle new compiler options. (gdc-convert-test): Handle CXXFLAGS, EXTRA_OBJC_SOURCES, and ARG_SETS test directives. (gdc-do-test): Only import modules in the test run directory. * gdc.dg/pr94777c.d: New test. * gdc.dg/pr96156b.d: New test. * gdc.dg/pr96157c.d: New test. * gdc.dg/simd_ctfe.d: New test. * gdc.dg/torture/simd17344.d: New test. * gdc.dg/torture/simd20052.d: New test. * gdc.dg/torture/simd6.d: New test. * gdc.dg/torture/simd7.d: New test. --- gcc/testsuite/gdc.dg/Wcastresult2.d | 2 +- gcc/testsuite/gdc.dg/asm1.d | 18 +-- gcc/testsuite/gdc.dg/asm2.d | 2 +- gcc/testsuite/gdc.dg/asm3.d | 10 +- gcc/testsuite/gdc.dg/gdc282.d | 6 +- gcc/testsuite/gdc.dg/imports/gdc170.d | 8 +- gcc/testsuite/gdc.dg/intrinsics.d | 36 +++--- gcc/testsuite/gdc.dg/pr101672.d | 2 +- gcc/testsuite/gdc.dg/pr90650a.d | 2 +- gcc/testsuite/gdc.dg/pr90650b.d | 2 +- gcc/testsuite/gdc.dg/pr94777a.d | 2 +- gcc/testsuite/gdc.dg/pr94777c.d | 62 +++++++++++ gcc/testsuite/gdc.dg/pr95250.d | 2 +- gcc/testsuite/gdc.dg/pr96156b.d | 17 +++ gcc/testsuite/gdc.dg/pr96157c.d | 40 +++++++ gcc/testsuite/gdc.dg/pr96869.d | 26 ++--- gcc/testsuite/gdc.dg/pr98277.d | 2 +- gcc/testsuite/gdc.dg/pr98457.d | 6 +- gcc/testsuite/gdc.dg/simd1.d | 8 -- gcc/testsuite/gdc.dg/simd2a.d | 8 -- gcc/testsuite/gdc.dg/simd2b.d | 8 -- gcc/testsuite/gdc.dg/simd2c.d | 8 -- gcc/testsuite/gdc.dg/simd2d.d | 8 -- gcc/testsuite/gdc.dg/simd2e.d | 8 -- gcc/testsuite/gdc.dg/simd2f.d | 8 -- gcc/testsuite/gdc.dg/simd2g.d | 8 -- gcc/testsuite/gdc.dg/simd2h.d | 8 -- gcc/testsuite/gdc.dg/simd2i.d | 8 -- gcc/testsuite/gdc.dg/simd2j.d | 8 -- gcc/testsuite/gdc.dg/simd7951.d | 1 + gcc/testsuite/gdc.dg/simd_ctfe.d | 87 +++++++++++++++ gcc/testsuite/gdc.dg/torture/gdc309.d | 1 + gcc/testsuite/gdc.dg/torture/pr94424.d | 16 +++ gcc/testsuite/gdc.dg/torture/pr94777b.d | 135 ----------------------- gcc/testsuite/gdc.dg/torture/simd17344.d | 11 ++ gcc/testsuite/gdc.dg/torture/simd20052.d | 17 +++ gcc/testsuite/gdc.dg/torture/simd6.d | 26 +++++ gcc/testsuite/gdc.dg/torture/simd7.d | 18 +++ gcc/testsuite/lib/gdc-utils.exp | 81 ++++++++++++-- 39 files changed, 435 insertions(+), 291 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr94777c.d create mode 100644 gcc/testsuite/gdc.dg/pr96156b.d create mode 100644 gcc/testsuite/gdc.dg/pr96157c.d create mode 100644 gcc/testsuite/gdc.dg/simd_ctfe.d create mode 100644 gcc/testsuite/gdc.dg/torture/simd17344.d create mode 100644 gcc/testsuite/gdc.dg/torture/simd20052.d create mode 100644 gcc/testsuite/gdc.dg/torture/simd6.d create mode 100644 gcc/testsuite/gdc.dg/torture/simd7.d diff --git a/gcc/testsuite/gdc.dg/Wcastresult2.d b/gcc/testsuite/gdc.dg/Wcastresult2.d index 56d2dd20e82..83d189a6adf 100644 --- a/gcc/testsuite/gdc.dg/Wcastresult2.d +++ b/gcc/testsuite/gdc.dg/Wcastresult2.d @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-Wcast-result" } +// { dg-options "-Wcast-result -Wno-deprecated" } void test() { diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d index dce36769370..1b249ee7b35 100644 --- a/gcc/testsuite/gdc.dg/asm1.d +++ b/gcc/testsuite/gdc.dg/asm1.d @@ -24,9 +24,9 @@ void parse3() { asm { "" [; } // { dg-error "expression expected, not ';'" "" { target *-*-* } .-1 } - // { dg-error "found 'EOF' when expecting ','" "" { target *-*-* } .-2 } - // { dg-error "found 'EOF' when expecting ']'" "" { target *-*-* } .-3 } - // { dg-error "found 'EOF' when expecting ';'" "" { target *-*-* } .-4 } + // { dg-error "found 'End of File' when expecting ','" "" { target *-*-* } .-2 } + // { dg-error "found 'End of File' when expecting ']'" "" { target *-*-* } .-3 } + // { dg-error "found 'End of File' when expecting ';'" "" { target *-*-* } .-4 } } void parse4() @@ -46,8 +46,8 @@ void semantic1() ; } asm { "" : : : : L1, L2; } - // { dg-error "goto skips declaration of variable asm1.semantic1.one" "" { target *-*-* } .-1 } - // { dg-error "goto skips declaration of variable asm1.semantic1.two" "" { target *-*-* } .-2 } + // { dg-error "'goto' skips declaration of variable 'asm1.semantic1.one'" "" { target *-*-* } .-1 } + // { dg-error "'goto' skips declaration of variable 'asm1.semantic1.two'" "" { target *-*-* } .-2 } { int two; L2: @@ -58,19 +58,19 @@ void semantic1() void semantic2a(X...)(X expr) { alias X[0] var1; - asm { "%0" : "=m" (var1); } // { dg-error "double 'double' is a type, not an lvalue" } + asm { "%0" : "=m" (var1); } // { dg-error "double' is a 'double' definition and cannot be modified" } } void semantic2() { - semantic2a(3.6); // { dg-error "template instance asm1.semantic2a!double error instantiating" } + semantic2a(3.6); // { dg-error "template instance 'asm1.semantic2a!double' error instantiating" } } void semantic3() { asm { - unknown; // { dg-error "undefined identifier" } + unknown; // { dg-error "undefined identifier 'unknown'" } } } @@ -86,6 +86,6 @@ void semantic4() { asm { - "%0" : : "m" (S4.foo); // { dg-error "template instance opDispatch!\"foo\" has no value" } + "%0" : : "m" (S4.foo); // { dg-error "template instance 'opDispatch!\"foo\"' has no value" } } } diff --git a/gcc/testsuite/gdc.dg/asm2.d b/gcc/testsuite/gdc.dg/asm2.d index bce0e41a60f..5b86e3564ef 100644 --- a/gcc/testsuite/gdc.dg/asm2.d +++ b/gcc/testsuite/gdc.dg/asm2.d @@ -3,6 +3,6 @@ module asm2; void test() { - asm const shared { } // { dg-error "const/immutable/shared/inout attributes are not allowed on asm blocks" } + asm const shared { } // { dg-error "'const'/'immutable'/'shared'/'inout' attributes are not allowed on 'asm' blocks" } } diff --git a/gcc/testsuite/gdc.dg/asm3.d b/gcc/testsuite/gdc.dg/asm3.d index 333d83ec99b..d792b2474be 100644 --- a/gcc/testsuite/gdc.dg/asm3.d +++ b/gcc/testsuite/gdc.dg/asm3.d @@ -2,23 +2,23 @@ // { dg-options "-Wall -Wdeprecated -Werror" } module asm3; -void test1() nothrow // { dg-error "nothrow function 'asm3.test1' may throw" } +void test1() nothrow { - asm { } // { dg-error "asm statement is assumed to throw - mark it with 'nothrow' if it does not" } + asm { } // { dg-error "'asm' statement is assumed to throw - mark it with 'nothrow' if it does not" } } void test2() pure { - asm { } // { dg-error "asm statement is assumed to be impure - mark it with 'pure' if it is not" } + asm { } // { dg-error "'asm' statement is assumed to be impure - mark it with 'pure' if it is not" } } void test3() @nogc { - asm { } // { dg-error "asm statement is assumed to use the GC - mark it with '@nogc' if it does not" } + asm { } // { dg-error "'asm' statement is assumed to use the GC - mark it with '@nogc' if it does not" } } void test4() @safe { - asm { } // { dg-error "asm statement is assumed to be @system - mark it with '@trusted' if it is not" } + asm { } // { dg-error "'asm' statement is assumed to be '@system' - mark it with '@trusted' if it is not" } } diff --git a/gcc/testsuite/gdc.dg/gdc282.d b/gcc/testsuite/gdc.dg/gdc282.d index ce840501d64..93e11fa0cbc 100644 --- a/gcc/testsuite/gdc.dg/gdc282.d +++ b/gcc/testsuite/gdc.dg/gdc282.d @@ -12,7 +12,7 @@ class C282a { } - void f282() // { dg-error "conflicts with gdc282.C282a.f282" } + void f282() // { dg-error "conflicts with previous declaration" } { } } @@ -27,7 +27,7 @@ class C282b { } - void f282() // { dg-error "conflicts with gdc282.C282b.f282" } + void f282() // { dg-error "conflicts with previous declaration" } { } } @@ -42,7 +42,7 @@ class C282c { } - void f282() // { dg-error "conflicts with gdc282.C282c.f282" } + void f282() // { dg-error "conflicts with previous declaration" } { } } diff --git a/gcc/testsuite/gdc.dg/imports/gdc170.d b/gcc/testsuite/gdc.dg/imports/gdc170.d index f9fea1f483c..aedef60c6b4 100644 --- a/gcc/testsuite/gdc.dg/imports/gdc170.d +++ b/gcc/testsuite/gdc.dg/imports/gdc170.d @@ -7,12 +7,12 @@ class bar(T) template foo(T) { - bar!T foo1(T2)() if (true) body { return null; } + bar!T foo1(T2)() if (true) do { return null; } bar!T foo2(T2)() { return null; } - bar!T foo3(T2 = void)() if (true) body { return null; } + bar!T foo3(T2 = void)() if (true) do { return null; } bar!T foo4(T2 = void)() { return null; } - void foo5(T2)(bar!T x) if (true) body {} + void foo5(T2)(bar!T x) if (true) do {} void foo6(T2)(bar!T x) {} - void foo7(T2 = void)(bar!T x) if (true) body {} + void foo7(T2 = void)(bar!T x) if (true) do {} void foo8(T2 = void)(bar!T x) {} } diff --git a/gcc/testsuite/gdc.dg/intrinsics.d b/gcc/testsuite/gdc.dg/intrinsics.d index d9ccc0ec5ce..dca40d2cf69 100644 --- a/gcc/testsuite/gdc.dg/intrinsics.d +++ b/gcc/testsuite/gdc.dg/intrinsics.d @@ -35,22 +35,6 @@ ulong test_bswap(ulong a) { return bswap(a); } int test_popcnt(uint a) { return popcnt(a); } // { dg-final { scan-tree-dump " __builtin_popcount(l|ll) " "original" } } int test_popcnt(ulong a) { return popcnt(a); } -// { dg-final { scan-tree-dump "\\(volatile ubyte \\*\\) a;" "original" } } -ubyte test_volatileLoad(ubyte *a) { return volatileLoad(a); } -// { dg-final { scan-tree-dump "\\(volatile ushort \\*\\) a;" "original" } } -ushort test_volatileLoad(ushort *a) { return volatileLoad(a); } -// { dg-final { scan-tree-dump "\\(volatile uint \\*\\) a;" "original" } } -uint test_volatileLoad(uint *a) { return volatileLoad(a); } -// { dg-final { scan-tree-dump "\\(volatile ulong \\*\\) a;" "original" } } -ulong test_volatileLoad(ulong *a) { return volatileLoad(a); } -// { dg-final { scan-tree-dump "\\(volatile ubyte \\*\\) a = b" "original" } } -void test_volatileStore(ubyte *a, ubyte b) { return volatileStore(a, b); } -// { dg-final { scan-tree-dump "\\(volatile ushort \\*\\) a = b" "original" } } -void test_volatileStore(ushort *a, ushort b) { return volatileStore(a, b); } -// { dg-final { scan-tree-dump "\\(volatile uint \\*\\) a = b" "original" } } -void test_volatileStore(uint *a, uint b) { return volatileStore(a, b); } -// { dg-final { scan-tree-dump "\\(volatile ulong \\*\\) a = b" "original" } } -void test_volatileStore(ulong *a, ulong b) { return volatileStore(a, b); } // { dg-final { scan-tree-dump " a r<< b;" "original" } } ubyte test_rol(ubyte a, uint b) { return rol!ubyte(a, b); } // { dg-final { scan-tree-dump " a r>> 31;" "original" } } @@ -140,6 +124,26 @@ real test_toPrecl(float a) { return toPrec!real(a); } real test_toPrecl(double a) { return toPrec!real(a); } real test_toPrecl(real a) { return toPrec!real(a); } +////////////////////////////////////////////////////// +// core.volatile + +// { dg-final { scan-tree-dump "\\(volatile ubyte \\*\\) a;" "original" } } +ubyte test_volatileLoad(ubyte *a) { return volatileLoad(a); } +// { dg-final { scan-tree-dump "\\(volatile ushort \\*\\) a;" "original" } } +ushort test_volatileLoad(ushort *a) { return volatileLoad(a); } +// { dg-final { scan-tree-dump "\\(volatile uint \\*\\) a;" "original" } } +uint test_volatileLoad(uint *a) { return volatileLoad(a); } +// { dg-final { scan-tree-dump "\\(volatile ulong \\*\\) a;" "original" } } +ulong test_volatileLoad(ulong *a) { return volatileLoad(a); } +// { dg-final { scan-tree-dump "\\(volatile ubyte \\*\\) a = b" "original" } } +void test_volatileStore(ubyte *a, ubyte b) { return volatileStore(a, b); } +// { dg-final { scan-tree-dump "\\(volatile ushort \\*\\) a = b" "original" } } +void test_volatileStore(ushort *a, ushort b) { return volatileStore(a, b); } +// { dg-final { scan-tree-dump "\\(volatile uint \\*\\) a = b" "original" } } +void test_volatileStore(uint *a, uint b) { return volatileStore(a, b); } +// { dg-final { scan-tree-dump "\\(volatile ulong \\*\\) a = b" "original" } } +void test_volatileStore(ulong *a, ulong b) { return volatileStore(a, b); } + ////////////////////////////////////////////////////// // core.stdc.stdarg diff --git a/gcc/testsuite/gdc.dg/pr101672.d b/gcc/testsuite/gdc.dg/pr101672.d index 292fd761fb1..8b337a4cf19 100644 --- a/gcc/testsuite/gdc.dg/pr101672.d +++ b/gcc/testsuite/gdc.dg/pr101672.d @@ -8,7 +8,7 @@ interface I101672 static int i101672; } -class A101672 : I101672 // { dg-error "class object.A101672 missing or corrupt object.d" } +class A101672 : I101672 { static int a101672; } diff --git a/gcc/testsuite/gdc.dg/pr90650a.d b/gcc/testsuite/gdc.dg/pr90650a.d index 57228cab19f..62b79941f20 100644 --- a/gcc/testsuite/gdc.dg/pr90650a.d +++ b/gcc/testsuite/gdc.dg/pr90650a.d @@ -10,5 +10,5 @@ class c void g () { - if (0 & [0] & c.f()) {} // { dg-error "array operation \\\[0\\\] & 0 & f\\(\\) without destination memory not allowed" } + if (0 & [0] & c.f()) {} // { dg-error "array operation .\\\[0\\\] & 0 & f\\(\\). without destination memory not allowed" } } diff --git a/gcc/testsuite/gdc.dg/pr90650b.d b/gcc/testsuite/gdc.dg/pr90650b.d index 2b3192ed2b6..11a02259481 100644 --- a/gcc/testsuite/gdc.dg/pr90650b.d +++ b/gcc/testsuite/gdc.dg/pr90650b.d @@ -9,5 +9,5 @@ class c } void g () { - if ([0] & c.f()) {} // { dg-error "array operation \\\[0\\\] & f\\(\\) without destination memory not allowed" } + if ([0] & c.f()) {} // { dg-error "array operation .\\\[0\\\] & f\\(\\). without destination memory not allowed" } } diff --git a/gcc/testsuite/gdc.dg/pr94777a.d b/gcc/testsuite/gdc.dg/pr94777a.d index a58fa557e35..d0cb5569e46 100644 --- a/gcc/testsuite/gdc.dg/pr94777a.d +++ b/gcc/testsuite/gdc.dg/pr94777a.d @@ -11,5 +11,5 @@ void f94777() this(this) { } } auto var = S94777(0); - variadic(var, S94777(1)); + variadic(var, S94777(1)); // { dg-error "cannot pass types with postblits or copy constructors as variadic arguments" } } diff --git a/gcc/testsuite/gdc.dg/pr94777c.d b/gcc/testsuite/gdc.dg/pr94777c.d new file mode 100644 index 00000000000..9b725c052c3 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr94777c.d @@ -0,0 +1,62 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94777 +// { dg-additional-options "-funittest" } +// { dg-do compile } + +void testVariadic(T)(int nargs, ...) +{ + import core.stdc.stdarg; + foreach(i; 0 .. nargs) + { + auto arg = va_arg!T(_argptr); + static if (__traits(compiles, arg.value)) + { + assert(arg.value == i); + } + else static if (__traits(compiles, arg[0])) + { + foreach (value; arg) + assert(value == i); + } + else + { + assert(arg == T.init); + } + } +} + +/******************************************/ + +struct Postblit +{ + static int count = 0; + int value; + this(this) { count++; } +} + +unittest +{ + auto a0 = Postblit(0); + auto a1 = Postblit(1); + auto a2 = Postblit(2); + testVariadic!Postblit(3, a0, a1, a2); // { dg-error "cannot pass types with postblits or copy constructors as variadic arguments" } + assert(Postblit.count == 3); +} + +/******************************************/ + +struct CopyConstructor +{ + static int count = 0; + int value; + this(int v) { this.value = v; } + this(ref typeof(this) other) { count++; this.value = other.value; } +} + +unittest +{ + auto a0 = CopyConstructor(0); + auto a1 = CopyConstructor(1); + auto a2 = CopyConstructor(2); + testVariadic!CopyConstructor(3, a0, a1, a2); // { dg-error "cannot pass types with postblits or copy constructors as variadic arguments" } + assert(CopyConstructor.count == 3); +} diff --git a/gcc/testsuite/gdc.dg/pr95250.d b/gcc/testsuite/gdc.dg/pr95250.d index dfb8abb732f..ba0adeac521 100644 --- a/gcc/testsuite/gdc.dg/pr95250.d +++ b/gcc/testsuite/gdc.dg/pr95250.d @@ -15,4 +15,4 @@ void* f(T)(T a, T b) } static assert(is(typeof(f!(void*)(null, null)) == void*)); -// { dg-error "static assert \(.*\) is false" "" { target *-*-* } .-1 } +// { dg-error "static assert: \(.*\) is false" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/gdc.dg/pr96156b.d b/gcc/testsuite/gdc.dg/pr96156b.d new file mode 100644 index 00000000000..ae79d568ec6 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr96156b.d @@ -0,0 +1,17 @@ +@safe unittest +{ + struct CustomString + { + @safe: + string _impl; + @property bool empty() const { return !_impl.length; } + } + + CustomString find(CustomString a, CustomString b) + { + return CustomString.init; + } + + auto r = find(CustomString("a"), CustomString("b")); + assert(r.empty); +} diff --git a/gcc/testsuite/gdc.dg/pr96157c.d b/gcc/testsuite/gdc.dg/pr96157c.d new file mode 100644 index 00000000000..8f48cbdc1b4 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr96157c.d @@ -0,0 +1,40 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96157 +// { dg-options "-fno-moduleinfo -fno-rtti" } +// { dg-do compile } + +struct CodepointSet +{ + CowArray!string data; +} + +struct CowArray(SP) +{ + ~this() + { + if (data.length) + refCount; + } + @property refCount() { return data[$-1]; } + + uint[] data; +} + +int ucmp() { return 1; } + +bool loadProperty () { + + CodepointSet target; + if (ucmp) + CodepointSet(); + else if (ucmp|| ucmp) + target = CodepointSet(); + else if (ucmp|| ucmp) + target = CodepointSet(); + else if (ucmp|| ucmp) + target = CodepointSet(); + else if (ucmp) + target = CodepointSet(); + else if (ucmp) + target = CodepointSet(); + return true; +} diff --git a/gcc/testsuite/gdc.dg/pr96869.d b/gcc/testsuite/gdc.dg/pr96869.d index c4ace30a546..348da1bcb3d 100644 --- a/gcc/testsuite/gdc.dg/pr96869.d +++ b/gcc/testsuite/gdc.dg/pr96869.d @@ -2,31 +2,31 @@ // { dg-do compile } __vector(float[0]) var01; -// { dg-error "0 byte vector type __vector\\\(float\\\[0\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "0 byte vector type '__vector\\\(float\\\[0\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float[3]) var02; -// { dg-error "12 byte vector type __vector\\\(float\\\[3\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "12 byte vector type '__vector\\\(float\\\[3\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float[][4]) var03; -// { dg-error "vector type __vector\\\(float\\\[\\\]\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(float\\\[\\\]\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float[4][4]) var04; -// { dg-error "vector type __vector\\\(float\\\[4\\\]\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(float\\\[4\\\]\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float[float][4]) var05; -// { dg-error "vector type __vector\\\(float\\\[float\\\]\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(float\\\[float\\\]\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float function()[4]) var06; -// { dg-error "vector type __vector\\\(float function\\\(\\\)\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(float function\\\(\\\)\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(float delegate()[4]) var07; -// { dg-error "vector type __vector\\\(float delegate\\\(\\\)\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(float delegate\\\(\\\)\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } enum E { a, b, c } __vector(E[4]) var08; -// { dg-error "vector type __vector\\\(E\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(E\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } struct S { float a; } __vector(S[4]) var09; -// { dg-error "vector type __vector\\\(S\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(S\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } class C { float a; } __vector(C[4]) var10; -// { dg-error "vector type __vector\\\(C\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(C\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(cfloat[4]) var11; -// { dg-error "vector type __vector\\\(cfloat\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(cfloat\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(bool[4]) var12; -// { dg-error "vector type __vector\\\(bool\\\[4\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(bool\\\[4\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } __vector(real[128]) var13; -// { dg-error "vector type __vector\\\(real\\\[128\\\]\\\) is not supported on this platform" "" { target *-*-* } .-1 } +// { dg-error "vector type '__vector\\\(real\\\[128\\\]\\\)' is not supported on this platform" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/gdc.dg/pr98277.d b/gcc/testsuite/gdc.dg/pr98277.d index d3b859fcbda..0dff142a6ef 100644 --- a/gcc/testsuite/gdc.dg/pr98277.d +++ b/gcc/testsuite/gdc.dg/pr98277.d @@ -7,7 +7,7 @@ enum Side right } -ref int getSide(Side side, ref int left, ref int right) +ref int getSide(Side side, return ref int left, return ref int right) { return side == Side.left ? left : right; } diff --git a/gcc/testsuite/gdc.dg/pr98457.d b/gcc/testsuite/gdc.dg/pr98457.d index bc0d8af5d4a..0cc83aca064 100644 --- a/gcc/testsuite/gdc.dg/pr98457.d +++ b/gcc/testsuite/gdc.dg/pr98457.d @@ -3,7 +3,7 @@ void main() { - writef!"%s"; // { dg-error "template instance writef!\"%s\" template .writef. is not defined" } - writef!"`%s"; // { dg-error "template instance writef!\"`%s\" template .writef. is not defined" } - writef!"%%s`"; // { dg-error "template instance writef!\"%%s`\" template .writef. is not defined" } + writef!"%s"; // { dg-error "template instance .writef!\"%s\". template .writef. is not defined" } + writef!"`%s"; // { dg-error "template instance .writef!\"`%s\". template .writef. is not defined" } + writef!"%%s`"; // { dg-error "template instance .writef!\"%%s`\". template .writef. is not defined" } } diff --git a/gcc/testsuite/gdc.dg/simd1.d b/gcc/testsuite/gdc.dg/simd1.d index 374dcae5e94..b25b99e3e1d 100644 --- a/gcc/testsuite/gdc.dg/simd1.d +++ b/gcc/testsuite/gdc.dg/simd1.d @@ -26,14 +26,6 @@ void test1() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); static assert(!__traits(compiles, v1 << 1)); static assert(!__traits(compiles, v1 >> 1)); static assert(!__traits(compiles, v1 >>> 1)); diff --git a/gcc/testsuite/gdc.dg/simd2a.d b/gcc/testsuite/gdc.dg/simd2a.d index b630a473b18..0fb391cc057 100644 --- a/gcc/testsuite/gdc.dg/simd2a.d +++ b/gcc/testsuite/gdc.dg/simd2a.d @@ -24,14 +24,6 @@ void test2a() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2b.d b/gcc/testsuite/gdc.dg/simd2b.d index 35c42880ce2..41a4eb3c34a 100644 --- a/gcc/testsuite/gdc.dg/simd2b.d +++ b/gcc/testsuite/gdc.dg/simd2b.d @@ -24,14 +24,6 @@ void test2b() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2c.d b/gcc/testsuite/gdc.dg/simd2c.d index 2f19e75a35b..a9957094998 100644 --- a/gcc/testsuite/gdc.dg/simd2c.d +++ b/gcc/testsuite/gdc.dg/simd2c.d @@ -24,14 +24,6 @@ void test2c() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2d.d b/gcc/testsuite/gdc.dg/simd2d.d index 9d378e4cdba..d578734368e 100644 --- a/gcc/testsuite/gdc.dg/simd2d.d +++ b/gcc/testsuite/gdc.dg/simd2d.d @@ -24,14 +24,6 @@ void test2d() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2e.d b/gcc/testsuite/gdc.dg/simd2e.d index 30d7c1aa165..d33574ad005 100644 --- a/gcc/testsuite/gdc.dg/simd2e.d +++ b/gcc/testsuite/gdc.dg/simd2e.d @@ -24,14 +24,6 @@ void test2e() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2f.d b/gcc/testsuite/gdc.dg/simd2f.d index f8448801dba..5845249e693 100644 --- a/gcc/testsuite/gdc.dg/simd2f.d +++ b/gcc/testsuite/gdc.dg/simd2f.d @@ -24,14 +24,6 @@ void test2f() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2g.d b/gcc/testsuite/gdc.dg/simd2g.d index 8e8bc15623c..ce438f2c3db 100644 --- a/gcc/testsuite/gdc.dg/simd2g.d +++ b/gcc/testsuite/gdc.dg/simd2g.d @@ -24,14 +24,6 @@ void test2g() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2h.d b/gcc/testsuite/gdc.dg/simd2h.d index f7542e83b8c..c631c760ffb 100644 --- a/gcc/testsuite/gdc.dg/simd2h.d +++ b/gcc/testsuite/gdc.dg/simd2h.d @@ -24,14 +24,6 @@ void test2h() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); v1 = v2 << 1; v1 = v2 >> 1; v1 = v2 >>> 1; diff --git a/gcc/testsuite/gdc.dg/simd2i.d b/gcc/testsuite/gdc.dg/simd2i.d index 2e3587dce77..6946c79987a 100644 --- a/gcc/testsuite/gdc.dg/simd2i.d +++ b/gcc/testsuite/gdc.dg/simd2i.d @@ -24,14 +24,6 @@ void test2i() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); static assert(!__traits(compiles, v1 << 1)); static assert(!__traits(compiles, v1 >> 1)); static assert(!__traits(compiles, v1 >>> 1)); diff --git a/gcc/testsuite/gdc.dg/simd2j.d b/gcc/testsuite/gdc.dg/simd2j.d index 7b607848580..ecfdbf3bbc1 100644 --- a/gcc/testsuite/gdc.dg/simd2j.d +++ b/gcc/testsuite/gdc.dg/simd2j.d @@ -24,14 +24,6 @@ void test2j() static assert(!__traits(compiles, v1 > v2)); static assert(!__traits(compiles, v1 <= v2)); static assert(!__traits(compiles, v1 >= v2)); - static assert(!__traits(compiles, v1 <> v2)); - static assert(!__traits(compiles, v1 !< v2)); - static assert(!__traits(compiles, v1 !> v2)); - static assert(!__traits(compiles, v1 !<> v2)); - static assert(!__traits(compiles, v1 <>= v2)); - static assert(!__traits(compiles, v1 !<= v2)); - static assert(!__traits(compiles, v1 !>= v2)); - static assert(!__traits(compiles, v1 !<>= v2)); static assert(!__traits(compiles, v1 << 1)); static assert(!__traits(compiles, v1 >> 1)); static assert(!__traits(compiles, v1 >>> 1)); diff --git a/gcc/testsuite/gdc.dg/simd7951.d b/gcc/testsuite/gdc.dg/simd7951.d index 99ce1510f8f..4e467ef0f96 100644 --- a/gcc/testsuite/gdc.dg/simd7951.d +++ b/gcc/testsuite/gdc.dg/simd7951.d @@ -19,4 +19,5 @@ void test7951_2() f1.array = v1; f2.array = v2; f3 = f1 + f2; + assert((cast(float[4])f3)[2] == 6); } diff --git a/gcc/testsuite/gdc.dg/simd_ctfe.d b/gcc/testsuite/gdc.dg/simd_ctfe.d new file mode 100644 index 00000000000..b254cf312cb --- /dev/null +++ b/gcc/testsuite/gdc.dg/simd_ctfe.d @@ -0,0 +1,87 @@ +// { dg-do compile } +import core.simd; + +// https://issues.dlang.org/show_bug.cgi?id=19627 +enum int[4] fail19627 = cast(int[4])int4(0); + +// https://issues.dlang.org/show_bug.cgi?id=19628 +enum ice19628a = int4.init[0]; +enum ice19628b = int4.init.array[0]; +enum ice19628c = (cast(int[4])int4.init.array)[0]; +enum ice19628d = (cast(int[4])int4.init)[0]; + +// https://issues.dlang.org/show_bug.cgi?id=19629 +enum fail19629a = int4(0)[0]; +enum fail19629b = int4(0).array[0]; +enum fail19629c = (cast(int[4])int4(0).array)[0]; +enum fail19628d = (cast(int[4])int4(0))[0]; + +// https://issues.dlang.org/show_bug.cgi?id=19630 +enum fail19630a = int4.init[1..2]; +enum fail19630b = int4.init.array[1..2]; +enum fail19630c = (cast(int[4])int4.init.array)[1..2]; +enum fail19630d = int4(0)[1..2]; +enum fail19630e = int4(0).array[1..2]; +enum fail19630f = (cast(int[4])int4(0).array)[1..2]; +enum fail19630g = (cast(int[4])int4.init)[1..2]; +enum fail19630h = (cast(int[4])int4(0))[1..2]; + +// Same tests as above, but use access via enum. +enum int4 V1 = int4.init; +enum int[4] V2 = int4.init.array; +enum int[4] V3 = cast(int[4])int4.init; +enum int[4] V4 = cast(int[4])int4.init.array; +enum int4 V5 = int4(0); +enum int[4] V6 = int4(0).array; +enum int[4] V7 = cast(int[4])int4(0); +enum int[4] V8 = cast(int[4])int4(0).array; + +// CTFE index tests +enum I1 = V1[0]; static assert(I1 == 0); +enum I2 = V2[0]; static assert(I2 == 0); +enum I3 = V3[0]; static assert(I3 == 0); +enum I4 = V4[0]; static assert(I4 == 0); +enum I5 = V5[0]; static assert(I5 == 0); +enum I6 = V6[0]; static assert(I6 == 0); +enum I7 = V7[0]; static assert(I7 == 0); +enum I8 = V8[0]; static assert(I8 == 0); + +// CTFE slice tests +enum S1 = V1[1..2]; static assert(S1 == [0]); +enum S2 = V2[1..2]; static assert(S2 == [0]); +enum S3 = V3[1..2]; static assert(S3 == [0]); +enum S4 = V4[1..2]; static assert(S4 == [0]); +enum S5 = V5[1..2]; static assert(S5 == [0]); +enum S6 = V6[1..2]; static assert(S6 == [0]); +enum S7 = V7[1..2]; static assert(S7 == [0]); +enum S8 = V8[1..2]; static assert(S8 == [0]); + +// Same tests as above, but use access via immutable. +//immutable int4 v1 = int4.init; // Cannot cast to immutable at compile time +immutable int[4] v2 = int4.init.array; +immutable int[4] v3 = cast(int[4])int4.init; +immutable int[4] v4 = cast(int[4])int4.init.array; +//immutable int4 v5 = int4(0); // Cannot cast to immutable at compile time +immutable int[4] v6 = int4(0).array; +immutable int[4] v7 = cast(int[4])int4(0); +immutable int[4] v8 = cast(int[4])int4(0).array; + +// CTFE index tests +//immutable i1 = v1[0]; static assert(i1 == 0); +immutable i2 = v2[0]; static assert(i2 == 0); +immutable i3 = v3[0]; static assert(i3 == 0); +immutable i4 = v4[0]; static assert(i4 == 0); +//immutable i5 = v5[0]; static assert(i5 == 0); +immutable i6 = v6[0]; static assert(i6 == 0); +immutable i7 = v7[0]; static assert(i7 == 0); +immutable i8 = v8[0]; static assert(i8 == 0); + +// CTFE slice tests +//immutable s1 = v1[1..2]; static assert(s1 == [0]); +immutable s2 = v2[1..2]; static assert(s2 == [0]); +immutable s3 = v3[1..2]; static assert(s3 == [0]); +immutable s4 = v4[1..2]; static assert(s4 == [0]); +//immutable s5 = v5[1..2]; static assert(s5 == [0]); +immutable s6 = v6[1..2]; static assert(s6 == [0]); +immutable s7 = v7[1..2]; static assert(s7 == [0]); +immutable s8 = v8[1..2]; static assert(s8 == [0]); diff --git a/gcc/testsuite/gdc.dg/torture/gdc309.d b/gcc/testsuite/gdc.dg/torture/gdc309.d index d14634a2f1f..acda2bb8f5a 100644 --- a/gcc/testsuite/gdc.dg/torture/gdc309.d +++ b/gcc/testsuite/gdc.dg/torture/gdc309.d @@ -1,4 +1,5 @@ // https://bugzilla.gdcproject.org/show_bug.cgi?id=309 +// { dg-additional-options "-Wno-deprecated" } // { dg-do run } // { dg-skip-if "needs gcc/config.d" { ! d_runtime } } diff --git a/gcc/testsuite/gdc.dg/torture/pr94424.d b/gcc/testsuite/gdc.dg/torture/pr94424.d index 2910c9ae139..dc30639ab2a 100644 --- a/gcc/testsuite/gdc.dg/torture/pr94424.d +++ b/gcc/testsuite/gdc.dg/torture/pr94424.d @@ -17,3 +17,19 @@ assert(__cmp([c2, c2], [c1, c1]) > 0); assert(__cmp([c2, c2], [c2, c1]) > 0); } + +@safe unittest +{ + struct C + { + char i; + this(char i) { this.i = i; } + } + + auto c1 = C(1); + auto c2 = C(2); + + assert(__cmp([c1, c1][], [c2, c2][]) < 0); + assert(__cmp([c2, c2], [c1, c1]) > 0); + assert(__cmp([c2, c2], [c2, c1]) > 0); +} diff --git a/gcc/testsuite/gdc.dg/torture/pr94777b.d b/gcc/testsuite/gdc.dg/torture/pr94777b.d index 2f0f9d9affb..e9da63fdc9d 100644 --- a/gcc/testsuite/gdc.dg/torture/pr94777b.d +++ b/gcc/testsuite/gdc.dg/torture/pr94777b.d @@ -27,42 +27,6 @@ void testVariadic(T)(int nargs, ...) /******************************************/ -struct Constructor -{ - static int count; - int value; - this(int v) { count++; this.value = v; } -} - -unittest -{ - auto a0 = Constructor(0); - auto a1 = Constructor(1); - auto a2 = Constructor(2); - testVariadic!Constructor(3, a0, a1, a2); - assert(Constructor.count == 3); -} - -/******************************************/ - -struct Postblit -{ - static int count = 0; - int value; - this(this) { count++; } -} - -unittest -{ - auto a0 = Postblit(0); - auto a1 = Postblit(1); - auto a2 = Postblit(2); - testVariadic!Postblit(3, a0, a1, a2); - assert(Postblit.count == 3); -} - -/******************************************/ - struct Destructor { static int count = 0; @@ -80,102 +44,3 @@ unittest } assert(Destructor.count == 3); } - -/******************************************/ - -struct CopyConstructor -{ - static int count = 0; - int value; - this(int v) { this.value = v; } - this(ref typeof(this) other) { count++; this.value = other.value; } -} - -unittest -{ - auto a0 = CopyConstructor(0); - auto a1 = CopyConstructor(1); - auto a2 = CopyConstructor(2); - testVariadic!CopyConstructor(3, a0, a1, a2); - // NOTE: Cpctors are not implemented yet. - assert(CopyConstructor.count == 0 || CopyConstructor.count == 3); -} - -/******************************************/ - -unittest -{ - struct Nested - { - int value; - } - - auto a0 = Nested(0); - auto a1 = Nested(1); - auto a2 = Nested(2); - testVariadic!Nested(3, a0, a1, a2); -} - -/******************************************/ - -unittest -{ - struct Nested2 - { - int value; - } - - void testVariadic2(int nargs, ...) - { - import core.stdc.stdarg; - foreach(i; 0 .. nargs) - { - auto arg = va_arg!Nested2(_argptr); - assert(arg.value == i); - } - } - - auto a0 = Nested2(0); - auto a1 = Nested2(1); - auto a2 = Nested2(2); - testVariadic2(3, a0, a1, a2); -} - -/******************************************/ - -struct EmptyStruct -{ -} - -unittest -{ - auto a0 = EmptyStruct(); - auto a1 = EmptyStruct(); - auto a2 = EmptyStruct(); - testVariadic!EmptyStruct(3, a0, a1, a2); -} - -/******************************************/ - -alias StaticArray = int[4]; - -unittest -{ - StaticArray a0 = 0; - StaticArray a1 = 1; - StaticArray a2 = 2; - // XBUG: Front-end rewrites static arrays as dynamic arrays. - //testVariadic!StaticArray(3, a0, a1, a2); -} - -/******************************************/ - -alias EmptyArray = void[0]; - -unittest -{ - auto a0 = EmptyArray.init; - auto a1 = EmptyArray.init; - auto a2 = EmptyArray.init; - testVariadic!EmptyArray(3, a0, a1, a2); -} diff --git a/gcc/testsuite/gdc.dg/torture/simd17344.d b/gcc/testsuite/gdc.dg/torture/simd17344.d new file mode 100644 index 00000000000..fd5ffbe8a3a --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/simd17344.d @@ -0,0 +1,11 @@ +// https://issues.dlang.org/show_bug.cgi?id=17344 +// { dg-additional-options "-mavx" { target avx_runtime } } +// { dg-do run { target { avx_runtime || vect_sizes_16B_8B } } } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } + +void main() +{ + __vector(int[4]) vec1 = 2, vec2 = vec1++; + assert(cast(int[4])vec1 == [3, 3, 3, 3]); + assert(cast(int[4])vec2 == [2, 2, 2, 2]); +} diff --git a/gcc/testsuite/gdc.dg/torture/simd20052.d b/gcc/testsuite/gdc.dg/torture/simd20052.d new file mode 100644 index 00000000000..4587351a851 --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/simd20052.d @@ -0,0 +1,17 @@ +// { dg-additional-options "-mavx2" { target avx2_runtime } } +// { dg-do run { target { avx2_runtime || vect_sizes_32B_16B } } } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } +import core.simd; + +auto test20052() +{ + struct S { long4 v; } + S s; + return s; +} + +void main() +{ + test20052(); +} + diff --git a/gcc/testsuite/gdc.dg/torture/simd6.d b/gcc/testsuite/gdc.dg/torture/simd6.d new file mode 100644 index 00000000000..d8de02edf72 --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/simd6.d @@ -0,0 +1,26 @@ +// { dg-additional-options "-mavx2" { target avx2_runtime } } +// { dg-do run { target { avx2_runtime || vect_sizes_32B_16B } } } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } +import core.simd; + +void test6a() +{ + // stack occasionally misaligned + float f = 0; + long4 v; + assert((cast(size_t)&v) % 32 == 0); + v += 1; +} + +void test6b() +{ + struct S {long4 v;} + S s; + assert((cast(size_t)&s) % 32 == 0); +} + +void main() +{ + test6a(); + test6b(); +} diff --git a/gcc/testsuite/gdc.dg/torture/simd7.d b/gcc/testsuite/gdc.dg/torture/simd7.d new file mode 100644 index 00000000000..6e890defca7 --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/simd7.d @@ -0,0 +1,18 @@ +// { dg-additional-options "-mavx2" { target avx2_runtime } } +// { dg-do run { target { avx2_runtime || vect_sizes_32B_16B } } } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } +import core.simd; + +double4 test7r(double4 v) +{ + return v; +} + +void main() +{ + // 32 bytes sliced down to 16 bytes + double4 v = 1; + double4 r = test7r(v); + assert(v[2] == r[2]); + assert(v[3] == r[3]); +} diff --git a/gcc/testsuite/lib/gdc-utils.exp b/gcc/testsuite/lib/gdc-utils.exp index 33c01450eb4..b3da7889bc0 100644 --- a/gcc/testsuite/lib/gdc-utils.exp +++ b/gcc/testsuite/lib/gdc-utils.exp @@ -35,6 +35,15 @@ proc gdc-convert-args { args } { set compilable_output_file_ext "di" lappend out "-H" + } elseif [string match "-HC" $arg] { + upvar 1 compilable_output_file_ext compilable_output_file_ext + upvar 1 name name + set compilable_output_file_ext "h" + lappend out "-fdump-c++-spec=[file rootname $name].h" + + } elseif [string match "-HC=verbose" $arg] { + lappend out "-fdump-c++-spec-verbose" + } elseif { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } { lappend out "-I$path" @@ -54,11 +63,11 @@ proc gdc-convert-args { args } { } elseif { [string match "-boundscheck" $arg] || [string match "-boundscheck=on" $arg] } { - lappend out "-fbounds-check" + lappend out "-fbounds-check=on" } elseif { [string match "-boundscheck=off" $arg] || [string match "-noboundscheck" $arg] } { - lappend out "-fno-bounds-check" + lappend out "-fbounds-check=off" } elseif [string match "-boundscheck=safeonly" $arg] { lappend out "-fbounds-check=safeonly" @@ -66,6 +75,12 @@ proc gdc-convert-args { args } { } elseif [string match "-c" $arg] { lappend out "-c" + } elseif [regexp -- {^-check=(\w+)=off} $arg pattern value] { + lappend out "-fno-check=$value" + + } elseif [string match "-checkaction=context" $arg] { + lappend out "-fcheckaction=context" + } elseif [string match "-d" $arg] { lappend out "-Wno-deprecated" @@ -79,23 +94,35 @@ proc gdc-convert-args { args } { } elseif [regexp -- {^-debug=(\w+)} $arg pattern value] { lappend out "-fdebug=$value" + } elseif [string match "-dip25" $arg] { + lappend out "-fpreview=dip25" + } elseif [string match "-dip1000" $arg] { - lappend out "-ftransition=dip1000" + lappend out "-fpreview=dip1000" - } elseif [string match "-dip25" $arg] { - lappend out "-ftransition=dip25" + } elseif [string match "-dip1008" $arg] { + lappend out "-fpreview=dip1008" } elseif [string match "-dw" $arg] { lappend out "-Wdeprecated" lappend out "-Wno-error" + } elseif [regexp -- {^-extern-std=([\w+]+)} $arg pattern value] { + lappend out "-fextern-std=$value" + } elseif [string match "-fPIC" $arg] { lappend out "-fPIC" + } elseif [string match "-fPIE" $arg] { + lappend out "-fPIE" + } elseif { [string match "-g" $arg] || [string match "-gc" $arg] } { lappend out "-g" + } elseif [string match "-ignore" $arg] { + lappend out "-fignore-unknown-pragmas" + } elseif [string match "-inline" $arg] { lappend out "-finline-functions" @@ -108,11 +135,17 @@ proc gdc-convert-args { args } { } elseif [string match "-O" $arg] { lappend out "-O2" + } elseif [regexp -- {^-preview=(\w+)} $arg pattern value] { + lappend out "-fpreview=[string tolower $value]" + } elseif [string match "-release" $arg] { lappend out "-frelease" + } elseif [regexp -- {^-revert=(\w+)} $arg pattern value] { + lappend out "-frevert=[string tolower $value]" + } elseif [regexp -- {^-transition=(\w+)} $arg pattern value] { - lappend out "-ftransition=$value" + lappend out "-ftransition=[string tolower $value]" } elseif [string match "-unittest" $arg] { lappend out "-funittest" @@ -126,6 +159,16 @@ proc gdc-convert-args { args } { } elseif [regexp -- {^-version=(\w+)} $arg pattern value] { lappend out "-fversion=$value" + } elseif [string match "-o-" $arg] { + upvar 2 compilable_do_what compilable_do_what + set compilable_do_what "compile" + + } elseif [string match "-vgc" $arg] { + lappend out "-ftransition=nogc" + + } elseif [string match "-vtemplates" $arg] { + lappend out "-ftransition=templates" + } elseif [string match "-vtls" $arg] { lappend out "-ftransition=tls" @@ -184,10 +227,15 @@ proc gdc-copy-file { srcdir filename } { # the test. # EXTRA_CPP_SOURCES: List of extra C++ files to build and link along with # the test. +# CXXFLAGS: list of extra arguments passed when compiling C++ +# sources defined in EXTRA_CPP_SOURCES. +# EXTRA_OBJC_SOURCES: List of extra Objective-C file to build and link along +# with the test. Currently not handled. # EXTRA_FILES: List of extra files to copy for the test runs. # PERMUTE_ARGS: The set of arguments to permute in multiple compiler # invocations. An empty set means only one permutation # with no arguments. +# ARG_SETS: Not handled. # LINK: Enables linking. # TEST_OUTPUT: The output expected from the compilation. # POST_SCRIPT: Not handled. @@ -241,6 +289,10 @@ proc gdc-convert-test { base test } { # LINK sets dg-do-what-default "link" set compilable_do_what "link" + } elseif [regexp -- {ARG_SETS} $copy_line] { + # ARG_SETS is not handled. + regsub -- {ARG_SETS.*$} $copy_line "" out_line + } elseif [regexp -- {POST_SCRIPT} $copy_line] { # POST_SCRIPT is not handled @@ -279,6 +331,16 @@ proc gdc-convert-test { base test } { lappend extra_sources "extra-files/$srcfile" } + } elseif [regexp -- {CXXFLAGS\s*:\s*(.*)} $copy_line match args] { + # Both C++ and D sources are compiled together, so include each + # other's command line flags too. + set new_option "{ dg-additional-options \"$args\" }" + regsub -- {CXXFLAGS.*$} $copy_line $new_option out_line + + } elseif [regexp -- {EXTRA_OBJC_SOURCES\s*:\s*(.*)} $copy_line match sources] { + # EXTRA_OBJC_SOURCES is not handled. + regsub -- {EXTRA_OBJC_SOURCES.*$} $copy_line "" out_line + } elseif [regexp -- {EXTRA_FILES\s*:\s*(.*)} $copy_line match files] { # EXTRA_FILES are appended to extra_files list foreach file $files { @@ -365,6 +427,11 @@ proc gdc-convert-test { base test } { } fail_compilation { + # Fail compilation tests only check for language errors from the + # front-end. No need to run all permutations of the default DFLAGS. + if { $PERMUTE_ARGS == $DEFAULT_DFLAGS } { + set PERMUTE_ARGS "" + } puts $fdout "// { dg-final { output-exists-not } }" } } @@ -434,7 +501,7 @@ proc gdc-do-test { testcases } { regexp -- "(.*)/(.+)/(.+)\.(.+)$" $test match base type name ext # Convert to DG test. - set imports [format "-I%s/%s" $base $type] + set imports [format "-I%s" $type] set cleanup_extra_files "" set compilable_do_what "compile" set filename "[gdc-convert-test $base $type/$name.$ext]"