aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-06-26 09:57:21 -0700
committerIan Lance Taylor <iant@golang.org>2023-06-26 09:57:21 -0700
commitaa1e672b5d99102b03eb5fb9c51609c45f62bff7 (patch)
tree886212591b1c9d127eaaf234a4a2e22452ea384a /gcc/testsuite/gdc.test
parent97e31a0a2a2d2273687fcdb4e5416aab1a2186e1 (diff)
parent3a39a31b8ae9c6465434aefa657f7fcc86f905c0 (diff)
downloadgcc-devel/gccgo.zip
gcc-devel/gccgo.tar.gz
gcc-devel/gccgo.tar.bz2
Merge from trunk revision 3a39a31b8ae9c6465434aefa657f7fcc86f905c0.devel/gccgo
Diffstat (limited to 'gcc/testsuite/gdc.test')
-rw-r--r--gcc/testsuite/gdc.test/compilable/shared.d66
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22739.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23799.d37
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/bug9631.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/cerrors.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail17646.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail19948.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail22857.d18
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail23816.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/imports/import22857.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/shared.d19
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21164.d3
-rw-r--r--gcc/testsuite/gdc.test/runnable/complex3.d31
13 files changed, 198 insertions, 28 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/shared.d b/gcc/testsuite/gdc.test/compilable/shared.d
index 695083a..647910e 100644
--- a/gcc/testsuite/gdc.test/compilable/shared.d
+++ b/gcc/testsuite/gdc.test/compilable/shared.d
@@ -11,34 +11,48 @@ ref shared(int) f(return shared ref int y)
}
// https://issues.dlang.org/show_bug.cgi?id=20908
+struct S
+{
+ int i = 2;
+}
+
+union U
+{
+ int i = 1;
+ bool b;
+}
+
void test20908()
{
- // shared locals (or struct members) should be able to be initialised:
- shared int x;
+ // shared locals (or struct members) should be able to be initialised:
+ shared int x;
- ref shared(int) fun()
- {
- static shared(int) val;
+ ref shared(int) fun()
+ {
+ static shared(int) val;
- // return by reference
- return val;
- }
+ // return by reference
+ return val;
+ }
- ref shared(int) fun2()
- {
- static shared(int)* val;
+ ref shared(int) fun2()
+ {
+ static shared(int)* val;
- // transfer pointer to reference
- return *val;
- }
+ // transfer pointer to reference
+ return *val;
+ }
- ref shared(int) fun3()
- {
- static shared(int)*** val;
+ ref shared(int) fun3()
+ {
+ static shared(int)*** val;
+
+ // Multiple indirections
+ return ***val;
+ }
- // Multiple indirections
- return ***val;
- }
+ shared S s;
+ shared U u;
}
// Simple tests for `DotVarExp`
@@ -130,3 +144,15 @@ void main()
{
auto b = new shared Class();
}
+
+// https://issues.dlang.org/show_bug.cgi?id=23790
+bool cas(shared bool*, bool, bool) { return true; }
+
+struct Argh
+{
+ bool locked;
+ void lock() shared
+ {
+ while(!cas(&locked, false, true)) {}
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22739.d b/gcc/testsuite/gdc.test/compilable/test22739.d
new file mode 100644
index 0000000..6aeb5d6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22739.d
@@ -0,0 +1,10 @@
+// https://issues.dlang.org/show_bug.cgi?id=22739
+
+extern(C++) auto f(T)()
+{
+ return T.init;
+}
+void main()
+{
+ f!int;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23799.d b/gcc/testsuite/gdc.test/compilable/test23799.d
new file mode 100644
index 0000000..0073516
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23799.d
@@ -0,0 +1,37 @@
+// https://issues.dlang.org/show_bug.cgi?id=23799
+
+// REQUIRED_ARGS: -betterC
+
+struct Data
+{
+ Data[] range;
+ string test;
+}
+
+Data[] foo()
+{
+ Data[] ret;
+ if (__ctfe)
+ {
+ Data tmp;
+ tmp.range ~= Data.init;
+ ret ~= tmp;
+ }
+ return ret;
+}
+
+void func(Data dat)()
+{
+}
+
+void bar(Data dat)()
+{
+ if (dat.test.length)
+ func!(dat.range[0])();
+}
+
+extern (C) void main()
+{
+ static immutable data = foo();
+ bar!(data[0])();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
index f456454..c980d76 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
fail_compilation/bug9631.d(20): Error: cannot implicitly convert expression `F()` of type `bug9631.T1!().F` to `bug9631.T2!().F`
---
*/
-
+// DISABLED: win32
template T1()
{
struct F { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/cerrors.d b/gcc/testsuite/gdc.test/fail_compilation/cerrors.d
index 3d69d41..db306c1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/cerrors.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/cerrors.d
@@ -1,10 +1,12 @@
/* REQUIRED_ARGS: -wi
TEST_OUTPUT:
---
-fail_compilation/cerrors.d(11): Error: C preprocessor directive `#if` is not supported, use `version` or `static if`
-fail_compilation/cerrors.d(11): Error: declaration expected, not `#`
-fail_compilation/cerrors.d(15): Warning: C preprocessor directive `#endif` is not supported
-fail_compilation/cerrors.d(15): Error: declaration expected, not `#`
+fail_compilation/cerrors.d(13): Error: C preprocessor directive `#if` is not supported, use `version` or `static if`
+fail_compilation/cerrors.d(13): Error: declaration expected, not `#`
+fail_compilation/cerrors.d(17): Error: C preprocessor directive `#endif` is not supported
+fail_compilation/cerrors.d(17): Error: declaration expected, not `#`
+fail_compilation/cerrors.d(21): Error: token string requires valid D tokens, not `#if`
+fail_compilation/cerrors.d(22): Deprecation: token string requires valid D tokens, not `#include`
---
*/
@@ -13,3 +15,9 @@ fail_compilation/cerrors.d(15): Error: declaration expected, not `#`
void test(wchar_t u);
#endif
+
+// https://issues.dlang.org/show_bug.cgi?id=23792
+enum s1 = q{
+#if 1
+#include <test>
+};
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17646.d b/gcc/testsuite/gdc.test/fail_compilation/fail17646.d
index 39e7cb9..2074b47 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail17646.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail17646.d
@@ -4,7 +4,7 @@ EXTRA_FILES: imports/fail17646.d
TEST_OUTPUT:
---
fail_compilation/imports/fail17646.d(10): Error: found `}` instead of statement
-fail_compilation/fail17646.d(11): Error: function `fail17646.runTests!"".runTests` has no `return` statement, but is expected to return a value of type `int`
+fail_compilation/fail17646.d(15): Error: template instance `allTestData!Modules` template `allTestData` is not defined
fail_compilation/fail17646.d(18): Error: template instance `fail17646.runTests!""` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19948.d b/gcc/testsuite/gdc.test/fail_compilation/fail19948.d
index 6122e41..e8a9e77 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail19948.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail19948.d
@@ -7,7 +7,7 @@ fail_compilation/fail19948.d(15): Error: function `fail19948.func(const(X))` is
fail_compilation/fail19948.d(15): cannot pass argument `X()` of type `fail19948.main.X` to parameter `const(fail19948.X)`
---
*/
-
+// DISABLED: win32
struct X {}
void main()
{
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22857.d b/gcc/testsuite/gdc.test/fail_compilation/fail22857.d
new file mode 100644
index 0000000..061eb62
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail22857.d
@@ -0,0 +1,18 @@
+// https://issues.dlang.org/show_bug.cgi?id=22857
+// EXTRA_FILES: imports/import22857.d
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/imports/import22857.d(4): Error: (expression) expected following `static if`
+fail_compilation/imports/import22857.d(4): Error: declaration expected, not `}`
+fail_compilation/fail22857.d(17): Error: template instance `unaryFun!()` template `unaryFun` is not defined
+---
+*/
+
+void isPrettyPropertyName()
+{
+ import imports.import22857;
+
+ unaryFun!();
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23816.d b/gcc/testsuite/gdc.test/fail_compilation/fail23816.d
new file mode 100644
index 0000000..574a712
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail23816.d
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=23816
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail23816.d(14): Error: opcode expected, not `NOP`
+---
+*/
+
+void main()
+{
+ asm
+ {
+ NOP;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/import22857.d b/gcc/testsuite/gdc.test/fail_compilation/imports/import22857.d
new file mode 100644
index 0000000..280c2eb
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/imports/import22857.d
@@ -0,0 +1,4 @@
+template unaryFun()
+{
+ static if
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/shared.d b/gcc/testsuite/gdc.test/fail_compilation/shared.d
index afdea64..8b94a79 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/shared.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/shared.d
@@ -259,3 +259,22 @@ void test_casting_safe() @safe
auto x1 = cast(int*)s;
auto x2 = cast(const(shared(int*)))s;
}
+
+#line 3100
+
+// https://issues.dlang.org/show_bug.cgi?id=23783
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/shared.d(3114): Error: direct access to shared `x` is not allowed, see `core.atomic`
+fail_compilation/shared.d(3115): Error: direct access to shared `x` is not allowed, see `core.atomic`
+---
+*/
+
+void test23783()
+{
+ shared int x = 3;
+ assert(x == 3);
+ bool b = x == 3;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21164.d b/gcc/testsuite/gdc.test/fail_compilation/test21164.d
index f42c4bc..a120024 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test21164.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21164.d
@@ -3,7 +3,8 @@ TEST_OUTPUT:
---
fail_compilation/imports/test21164d.d(3): Error: (expression) expected following `static if`
fail_compilation/imports/test21164d.d(3): Error: found `}` instead of statement
-fail_compilation/test21164.d(11): Error: template instance `test21164a.D!(R!(O(), 1))` error instantiating
+fail_compilation/imports/test21164a.d(5): Error: undefined identifier `I`
+fail_compilation/test21164.d(12): Error: template instance `test21164a.D!(R!(O(), 1))` error instantiating
---
*/
import imports.test21164a;
diff --git a/gcc/testsuite/gdc.test/runnable/complex3.d b/gcc/testsuite/gdc.test/runnable/complex3.d
new file mode 100644
index 0000000..7167b0b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/complex3.d
@@ -0,0 +1,31 @@
+// https://issues.dlang.org/show_bug.cgi?id=23778
+
+
+enum __c_long_double : double;
+
+alias __c_long_double c_long_double;
+
+struct _Complex
+{
+ c_long_double re;
+ c_long_double im;
+}
+
+version (all) // bug to test
+{
+ enum __c_complex_real : _Complex;
+ alias c_complex_real = __c_complex_real;
+}
+else // works
+ enum c_complex_real : _Complex;
+
+c_complex_real toNative2(real re, real im)
+{
+ return c_complex_real(re, im);
+}
+
+void main()
+{
+ c_complex_real n = toNative2(123, 456);
+ assert(123 == n.re && 456 == n.im);
+}