1 | // RUN: %clang_cfi -lm -o %t1 %s |
2 | // RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s |
3 | // RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s |
4 | |
5 | // This test uses jump tables containing PC-relative references to external |
6 | // symbols, which the Mach-O object writer does not currently support. |
7 | // The test passes on i386 Darwin and fails on x86_64, hence unsupported instead of xfail. |
8 | // UNSUPPORTED: darwin |
9 | |
10 | #include <stdlib.h> |
11 | #include <stdio.h> |
12 | #include <math.h> |
13 | |
14 | int main(int argc, char **argv) { |
15 | // CFI: 1 |
16 | fprintf(stderr, format: "1\n" ); |
17 | |
18 | double (*fn)(double); |
19 | if (argv[1][0] == 's') |
20 | fn = sin; |
21 | else |
22 | fn = cos; |
23 | |
24 | fn(atof(nptr: argv[2])); |
25 | |
26 | // CFI: 2 |
27 | fprintf(stderr, format: "2\n" ); |
28 | } |
29 | |