aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/compilable')
-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
3 files changed, 93 insertions, 20 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])();
+}