blob: a9b0799b18484e00e5ed887c7b4034d770b318c2 [file] [log] [blame]
Stephen Hines6d186232014-11-26 17:56:19 -08001// RUN: %clangxx -fsanitize=return -g %s -O3 -o %t
2// RUN: not %run %t 2>&1 | FileCheck %s
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07003// RUN: UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE
Stephen Hines2d1fdb22014-05-28 23:58:16 -07004
Stephen Hines6d186232014-11-26 17:56:19 -08005// CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value
Stephen Hines2d1fdb22014-05-28 23:58:16 -07006int f() {
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07007// Slow stack unwinding is not available on Darwin for now, see
Stephen Hines6d186232014-11-26 17:56:19 -08008// https://code.google.com/p/address-sanitizer/issues/detail?id=137
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07009// CHECK-Linux-STACKTRACE: #0 {{.*}}f(){{.*}}missing_return.cpp:[[@LINE-3]]
10// CHECK-FreeBSD-STACKTRACE: #0 {{.*}}f(void){{.*}}missing_return.cpp:[[@LINE-4]]
Stephen Hines2d1fdb22014-05-28 23:58:16 -070011}
12
13int main(int, char **argv) {
14 return f();
15}