]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/testsuite/gdc.test/compilable/noreturn1.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / noreturn1.d
index e21adc476c940255dd4f05085de022cea56b4f19..7517bb26e0d78adc05e872685c6f65f04460ce4a 100644 (file)
@@ -1,21 +1,66 @@
 /*
+REQUIRED_ARGS: -w
 TEST_OUTPUT:
 ---
 noreturn
 ---
+
+Basic properties and usage mentioned in the DIP:
+https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1034.md
 */
 
 alias noreturn = typeof(*null);
 pragma(msg, noreturn);
 
-noreturn exits(int* p) { *p = 3; }
+static assert(!is(noreturn == void));
+
+// Fails
+// static assert(is( typeof([]) == noreturn[] ));
+// static assert(is( typeof([][0]) == noreturn ));
+
+static assert(is( typeof(assert(0)) == noreturn ));
+
+// Does not parse yet
+// static assert(is( typeof(throw new Exception()) == noreturn ));
+
+static assert(is(noreturn == noreturn));
+static assert(!is(noreturn == const noreturn));
+static assert(is(noreturn : const noreturn));
+
+static assert(!is(noreturn == int));
+static assert(is(noreturn : int));
+
+// Covariance
+static assert(is(noreturn[] : int[]));
+static assert(is(noreturn* : int*));
+static assert(is(noreturn function() : int function()));
+static assert(is(noreturn delegate() : int delegate()));
+
+// Reject inverse conversions
+static assert(!is(int[]          : noreturn[]));
+static assert(!is(int*           : noreturn*));
+static assert(!is(int function() : noreturn function()));
+static assert(!is(int delegate() : noreturn delegate()));
+
+static assert(noreturn.mangleof == "Nn"); // Changed from b due to conflicts with bool
+static assert(noreturn.sizeof == 0);
+static assert(noreturn.alignof == 0);
+
+static assert((noreturn*).sizeof == (int*).sizeof);
+static assert((noreturn[]).sizeof == (int[]).sizeof);
+
+version (DigitalMars)
+    noreturn exits(int* p) { *p = 3; }
 
 noreturn exit();
 
+noreturn pureexits() @nogc nothrow pure @safe { assert(0); }
+
+noreturn callpureexits() { pureexits(); }
+
 int test1(int i)
 {
     if (exit())
         return i + 1;
     return i - 1;
 }
-