brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 1b09672 Raw
26 lines · cpp
1// RUN: %clang %S/Inputs/returns-unexpectedly.c -O3 -c -o %t.ru.o2// RUN: %clangxx -fsanitize=unreachable -O3 -o %t %s %t.ru.o3// RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN4// RUN: not %run %t noreturn-callee-marked 2>&1 | FileCheck %s -check-prefix=NORETURN15// RUN: not %run %t noreturn-caller-marked 2>&1 | FileCheck %s -check-prefix=NORETURN26 7#include <string.h>8 9void __attribute__((noreturn)) callee_marked_noreturn() {10  // NORETURN1: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution reached an unreachable program point11}12 13extern "C" void __attribute__((noreturn)) returns_unexpectedly();14 15int 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 point18    __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 point23    returns_unexpectedly();24  return 0;25}26