aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/defines.c28
-rw-r--r--gcc/testsuite/gdc.test/compilable/nogc.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22626.d23
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23076.d38
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23142.d19
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23174.d58
-rw-r--r--gcc/testsuite/gdc.test/compilable/testdefines.d14
-rw-r--r--gcc/testsuite/gdc.test/compilable/testdip1008.d19
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/mixin_template.d10
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/noreturn.d18
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/template_decl.d9
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21477.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test23159.d22
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/traits.d18
14 files changed, 301 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/imports/defines.c b/gcc/testsuite/gdc.test/compilable/imports/defines.c
new file mode 100644
index 0000000..6bd0736
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/defines.c
@@ -0,0 +1,28 @@
+/* */
+
+#define CC 'c'
+_Static_assert(CC == 'c', "1");
+
+#define I32 3
+_Static_assert(I32 == 3, "3");
+
+#define U32 4U
+_Static_assert(U32 == 4U, "4");
+
+#define I64 5L
+_Static_assert(I64 == 5U, "5");
+
+#define U64 6UL
+_Static_assert(U64 == 6UL, "6");
+
+#define F32 7.0f
+_Static_assert(F32 == 7.0f, "7");
+
+#define F64 8.0f
+_Static_assert(F64 == 8.0, "8");
+
+#define F80 9.0f
+_Static_assert(F80 == 9.0L, "9");
+
+#define SSS "hello"
+_Static_assert(SSS[0] == 'h', "10");
diff --git a/gcc/testsuite/gdc.test/compilable/nogc.d b/gcc/testsuite/gdc.test/compilable/nogc.d
index 2751801..6ce5094 100644
--- a/gcc/testsuite/gdc.test/compilable/nogc.d
+++ b/gcc/testsuite/gdc.test/compilable/nogc.d
@@ -109,3 +109,12 @@ auto foo13550() @nogc
}
return &bar;
}
+
+// https://issues.dlang.org/show_bug.cgi?id=19285
+
+void f(bool cond, string s) @nogc {
+ auto inner() { return s; }
+ alias Unused1 = typeof(inner); // OK
+ alias Unused2 = typeof(&inner); // (Does not) INFERS GC (anymore)
+ enum Unused3 = __traits(compiles , &inner);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22626.d b/gcc/testsuite/gdc.test/compilable/test22626.d
new file mode 100644
index 0000000..5f72eb6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22626.d
@@ -0,0 +1,23 @@
+// https://issues.dlang.org/show_bug.cgi?id=22626
+// REQUIRED_ARGS: -preview=nosharedaccess
+
+shared int k;
+
+class Oops
+{
+ shared int a;
+ shared int* pa;
+ synchronized void oops()
+ {
+ // this should compile since the function is synchronized
+ // and `a` is accessed through `this`.
+ a = 2;
+
+ // this shouldn't compile because synchronized guards
+ // only accesses to the first level of dereferencing
+ static assert (!__traits(compiles, *pa = 2));
+
+ // this shouldn't compile `k` is a field of class `Oops`
+ static assert (!__traits(compiles, k = 2));
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23076.d b/gcc/testsuite/gdc.test/compilable/test23076.d
new file mode 100644
index 0000000..10a0c2f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23076.d
@@ -0,0 +1,38 @@
+/* REQUIRED_ARGS: -O -inline
+ */
+
+// https://issues.dlang.org/show_bug.cgi?id=23076
+
+struct S
+{
+ int depthLow = 0;
+ int depthHigh = 30000;
+
+ void fun(int* pixels)
+ {
+ float b = depthLow;
+ int depthA = cast(int)(b);
+ int depthB = cast(short)(cast(float)depthHigh * cast(float)depthLow);
+ pixels[depthA] = depthB;
+ }
+}
+
+/**********************/
+
+float mul3(float a, float b, float t)
+{
+ return t * b * a;
+}
+
+class A
+{
+ ushort depthLow = 0;
+ ushort depthHigh = 30000;
+
+ void fun(short* pixels)
+ {
+ short depthA = (cast(short)(mul3(depthHigh, depthLow, 0)));
+ short depthB = (cast(short)(mul3(depthLow, depthHigh, 0)));
+ pixels[depthA] = depthB;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23142.d b/gcc/testsuite/gdc.test/compilable/test23142.d
new file mode 100644
index 0000000..28bb691
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23142.d
@@ -0,0 +1,19 @@
+// https://issues.dlang.org/show_bug.cgi?id=23142
+
+struct Foo
+{
+ int x;
+
+scope:
+ void func()
+ {
+ }
+
+ unittest
+ {
+ }
+
+ static void func2()
+ {
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23174.d b/gcc/testsuite/gdc.test/compilable/test23174.d
new file mode 100644
index 0000000..9047fd7
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23174.d
@@ -0,0 +1,58 @@
+// https://issues.dlang.org/show_bug.cgi?id=23174
+
+alias AliasSeq(T...) = T;
+
+template staticMap(alias fun, args...)
+{
+ alias staticMap = AliasSeq!();
+ static foreach(arg; args)
+ staticMap = AliasSeq!(staticMap, fun!arg);
+}
+
+template Filter(alias pred, args...)
+{
+ alias Filter = AliasSeq!();
+ static foreach (arg; args)
+ static if (pred!arg)
+ Filter = AliasSeq!(Filter, arg);
+}
+
+struct Fields(T)
+{
+ private static alias toField(alias e) = Field!(__traits(identifier, e));
+ alias fields = staticMap!(toField, T.tupleof);
+
+ static alias map(alias F) = staticMap!(F, fields);
+ static alias filter(alias pred) = Filter!(pred, fields);
+}
+
+struct Field(string n)
+{
+ enum name = n;
+}
+
+struct Foo
+{
+ int a;
+}
+
+void test23174()
+{
+ Foo value;
+
+ enum toName(alias e) = e.name;
+ enum pred(alias e) = true;
+
+ alias a = Fields!(Foo).filter!(pred); // works
+ static assert(is(a == AliasSeq!(Field!"a")));
+
+ alias b = Fields!(Foo).map!(toName); // works
+ static assert(b == AliasSeq!("a"));
+
+ alias c = Fields!(Foo).init.filter!(pred); // works
+ static assert(is(c == AliasSeq!(Field!"a")));
+
+ // OK <- Error: alias `d` cannot alias an expression `Fields().tuple("a")`
+ alias d = Fields!(Foo).init.map!(toName);
+ static assert(d == AliasSeq!("a"));
+}
diff --git a/gcc/testsuite/gdc.test/compilable/testdefines.d b/gcc/testsuite/gdc.test/compilable/testdefines.d
new file mode 100644
index 0000000..4507266
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/testdefines.d
@@ -0,0 +1,14 @@
+// EXTRA_FILES: imports/defines.c
+import imports.defines;
+
+static assert(CC == 'c');
+static assert(I32 == 3);
+static assert(U32 == 4);
+static assert(I64 == 5);
+static assert(U64 == 6);
+
+static assert(F32 == 7.0f);
+static assert(F64 == 8.0);
+static assert(F80 == 9.0L);
+
+static assert(SSS == "hello");
diff --git a/gcc/testsuite/gdc.test/compilable/testdip1008.d b/gcc/testsuite/gdc.test/compilable/testdip1008.d
index 5e024fe..54d404c 100644
--- a/gcc/testsuite/gdc.test/compilable/testdip1008.d
+++ b/gcc/testsuite/gdc.test/compilable/testdip1008.d
@@ -13,9 +13,28 @@ int bar()
}
}
+void throwQualifiers() @safe @nogc pure
+{
+ throw new Exception("baz");
+}
+
+bool testThrowQualifiers()
+{
+ try
+ {
+ throwQualifiers();
+ } catch (Exception e)
+ {
+ return true;
+ }
+
+ return false;
+}
void foo()
{
enum r = bar();
static assert(r == 7);
+
+ static assert(testThrowQualifiers());
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/mixin_template.d b/gcc/testsuite/gdc.test/fail_compilation/mixin_template.d
new file mode 100644
index 0000000..b088da8
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/mixin_template.d
@@ -0,0 +1,10 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/mixin_template.d(10): Error: mixin `mixin_template.f!1` - `f` is a function, not a template
+---
+*/
+string f() {
+ return "int i;";
+}
+mixin f!1;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
index 696081a..d47d449 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
@@ -118,3 +118,21 @@ enum forceInClassRef = inClassRef();
*/
enum throwEnum = throw new Exception("");
+
+
+/*
+https://issues.dlang.org/show_bug.cgi?id=23063
+
+TEST_OUTPUT:
+---
+fail_compilation/noreturn.d(135): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation/noreturn.d(138): called from here: `func()`
+---
+*/
+noreturn func()
+{
+ noreturn a;
+ return a;
+}
+
+enum f = func();
diff --git a/gcc/testsuite/gdc.test/fail_compilation/template_decl.d b/gcc/testsuite/gdc.test/fail_compilation/template_decl.d
new file mode 100644
index 0000000..d986dd6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/template_decl.d
@@ -0,0 +1,9 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/template_decl.d(8): Error: `{` expected after template parameter list, not `(`
+fail_compilation/template_decl.d(8): Error: declaration expected, not `(`
+---
+*/
+template b(alias d)() {
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21477.d b/gcc/testsuite/gdc.test/fail_compilation/test21477.d
new file mode 100644
index 0000000..c9c7c7f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21477.d
@@ -0,0 +1,16 @@
+/* REQUIRED_ARGS: -betterC
+TEST_OUTPUT:
+---
+fail_compilation/test21477.d(103): Error: expression `[1]` uses the GC and cannot be used with switch `-betterC`
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=21477
+
+#line 100
+
+int test()
+{
+ int[] foo = [1];
+ return 0;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23159.d b/gcc/testsuite/gdc.test/fail_compilation/test23159.d
new file mode 100644
index 0000000..cdafc61
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test23159.d
@@ -0,0 +1,22 @@
+// https://issues.dlang.org/show_bug.cgi?id=23159
+
+// REQUIRED_ARGS: -betterC
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test23159.d(14): Error: `scope(failure)` cannot be used with -betterC
+fail_compilation/test23159.d(18): Error: `scope(success)` cannot be used with -betterC
+---
+*/
+
+void main()
+{
+ scope(failure)
+ {
+ int a;
+ }
+ scope(success)
+ {
+ int a;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/traits.d b/gcc/testsuite/gdc.test/fail_compilation/traits.d
index 8c16afe..21f3f57 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/traits.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/traits.d
@@ -116,3 +116,21 @@ pragma(msg, __traits(hasCopyConstructor));
pragma(msg, __traits(hasCopyConstructor, S()));
pragma(msg, __traits(hasPostblit));
pragma(msg, __traits(hasPostblit, S()));
+
+/********************************************
+https://issues.dlang.org/show_bug.cgi?id=23178
+
+TEST_OUTPUT:
+---
+fail_compilation/traits.d(701): Error: alias `traits.a` cannot alias an expression `true`
+fail_compilation/traits.d(702): Error: alias `traits.b` cannot alias an expression `false`
+fail_compilation/traits.d(703): Error: alias `traits.c` cannot alias an expression `"Object"`
+fail_compilation/traits.d(704): while evaluating `pragma(msg, a)`
+---
+*/
+#line 700
+
+alias a = __traits(compiles, 1);
+alias b = __traits(isIntegral, 1.1);
+alias c = __traits(identifier, Object);
+pragma(msg, a, b, c);