Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / ubsan / TestCases / Misc / unreachable.cpp
blob1b096721ce9ca65a75489d6d7277930a9f6480ae
1 // RUN: %clang %S/Inputs/returns-unexpectedly.c -O3 -c -o %t.ru.o
2 // RUN: %clangxx -fsanitize=unreachable -O3 -o %t %s %t.ru.o
3 // RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN
4 // RUN: not %run %t noreturn-callee-marked 2>&1 | FileCheck %s -check-prefix=NORETURN1
5 // RUN: not %run %t noreturn-caller-marked 2>&1 | FileCheck %s -check-prefix=NORETURN2
7 #include <string.h>
9 void __attribute__((noreturn)) callee_marked_noreturn() {
10 // NORETURN1: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution reached an unreachable program point
13 extern "C" void __attribute__((noreturn)) returns_unexpectedly();
15 int main(int, char **argv) {
16 if (strcmp(argv[1], "builtin") == 0)
17 // BUILTIN: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution reached an unreachable program point
18 __builtin_unreachable();
19 else if (strcmp(argv[1], "noreturn-callee-marked") == 0)
20 callee_marked_noreturn();
21 else if (strcmp(argv[1], "noreturn-caller-marked") == 0)
22 // NORETURN2: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution reached an unreachable program point
23 returns_unexpectedly();
24 return 0;