summaryrefslogtreecommitdiffstats
path: root/tests/codegen/noreturn-uninhabited.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen/noreturn-uninhabited.rs')
-rw-r--r--tests/codegen/noreturn-uninhabited.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codegen/noreturn-uninhabited.rs b/tests/codegen/noreturn-uninhabited.rs
new file mode 100644
index 000000000..49f93cf62
--- /dev/null
+++ b/tests/codegen/noreturn-uninhabited.rs
@@ -0,0 +1,31 @@
+// compile-flags: -g -C no-prepopulate-passes
+
+#![crate_type = "lib"]
+
+#[derive(Clone, Copy)]
+pub enum EmptyEnum {}
+
+#[no_mangle]
+pub fn empty(x: &EmptyEnum) -> EmptyEnum {
+ // CHECK: @empty({{.*}}) unnamed_addr #0
+ // CHECK-NOT: ret void
+ // CHECK: call void @llvm.trap()
+ // CHECK: unreachable
+ *x
+}
+
+pub struct Foo(String, EmptyEnum);
+
+#[no_mangle]
+pub fn foo(x: String, y: &EmptyEnum) -> Foo {
+ // CHECK: @foo({{.*}}) unnamed_addr #0
+ // CHECK-NOT: ret %Foo
+ // CHECK: call void @llvm.trap()
+ // CHECK: unreachable
+ Foo(x, *y)
+}
+
+// CHECK: attributes #0 = {{{.*}} noreturn {{.*}}}
+
+// CHECK: DISubprogram(name: "empty", {{.*}} DIFlagNoReturn
+// CHECK: DISubprogram(name: "foo", {{.*}} DIFlagNoReturn