brintos

brintos / llvm-project-archived public Read only

0
0
Text · 609 B · 183e627 Raw
28 lines · c
1// RUN: %clang -o %t1 %s2// RUN: %t1 2>&1 | FileCheck --check-prefix=NCFI %s3 4// RUN: %clang_cfi -o %t2 %s5// RUN: %expect_crash %t2 2>&1 | FileCheck --check-prefix=CFI %s6 7// RUN: %clang_cfi_diag -g -o %t3 %s8// RUN: %t3 2>&1 | FileCheck --check-prefix=CFI-DIAG %s9 10#include <stdio.h>11 12void f() {13}14 15int main() {16  // CFI: 117  // NCFI: 118  fprintf(stderr, "1\n");19 20  // CFI-DIAG: runtime error: control flow integrity check for type 'void (int)' failed during indirect function call21  // CFI-DIAG: f defined here22  ((void (*)(int))f)(42); // UB here23 24  // CFI-NOT: 225  // NCFI: 226  fprintf(stderr, "2\n");27}28