summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/longjmp.cpp
blob: a8abca6017586f4ed2ee54bdfedb229dbf53bfa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s

#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>

int foo(jmp_buf env) {
  longjmp(env, 42);
}

int main() {
  jmp_buf env;
  if (setjmp(env) == 42) {
    fprintf(stderr, "JUMPED\n");
    return 0;
  }
  foo(env);
  fprintf(stderr, "FAILED\n");
  return 0;
}

// CHECK-NOT: FAILED
// CHECK: JUMPED
OpenPOWER on IntegriCloud