xref: /llvm-project/clang/test/AST/arithmetic-fence-builtin.c (revision 7e59223ac4b045178c287a56154113d5989572f4)
1 // Tests without serialization:
2 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu %s \
3 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
4 //
5 // RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu %s \
6 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
7 //
8 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s \
9 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
10 //
11 // RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -DFAST -mreassociate %s \
12 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
13 //
14 // RUN: %clang_cc1 -ast-dump -triple i386-pc-linux-gnu -DFAST -mreassociate %s \
15 // RUN: -fprotect-parens \
16 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
17 //
18 // RUN: %clang_cc1 -ast-dump -triple aarch64-unknown-linux-gnu -DFAST -mreassociate %s \
19 // RUN: -fprotect-parens \
20 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
21 //
22 // Tests with serialization:
23 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-pch -o %t %s
24 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -include-pch %t -ast-dump-all /dev/null \
25 // RUN: | FileCheck %s --strict-whitespace
26 //
27 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-pch -o %t %s
28 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -include-pch %t -ast-dump-all /dev/null \
29 // RUN: | FileCheck %s --strict-whitespace
30 //
31 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DFAST -mreassociate %s \
32 // RUN: -emit-pch -o %t
33 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -include-pch %t -ast-dump-all /dev/null \
34 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
35 //
36 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -DFAST -mreassociate %s \
37 // RUN: -emit-pch -o %t
38 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -include-pch %t -ast-dump-all /dev/null \
39 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK1
40 //
41 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DFAST -mreassociate %s \
42 // RUN:   -fprotect-parens -emit-pch -o %t
43 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -include-pch %t -ast-dump-all /dev/null -fprotect-parens\
44 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
45 //
46 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -DFAST -mreassociate %s \
47 // RUN:   -fprotect-parens -emit-pch -o %t
48 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -include-pch %t -ast-dump-all /dev/null -fprotect-parens\
49 // RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK,CHECK2
50 
51 int v;
addit(float a,float b)52 int addit(float a, float b) {
53 
54   v = __arithmetic_fence(a + b);
55 
56   v = (a + b);
57 
58   return 0;
59 }
60 //CHECK:| `-CompoundStmt {{.*}}
61 //CHECK-NEXT:|   |-BinaryOperator {{.*}} 'int' '='
62 //CHECK-NEXT:|   | |-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'v' 'int'
63 //CHECK-NEXT:|   | `-ImplicitCastExpr {{.*}}
64 //CHECK-NEXT:|   |   `-CallExpr {{.*}} 'float'
65 //CHECK-NEXT:|   |     |-ImplicitCastExpr {{.*}}
66 //CHECK-NEXT:|   |     | `-DeclRefExpr {{.*}}' Function {{.*}} '__arithmetic_fence'{{.*}}
67 //CHECK1-NOT:|   |     | `-DeclRefExpr {{.*}}' Function{{.*}} '__arithmetic_fence' 'void ()'
68 //CHECK2:|   |     | `-DeclRefExpr {{.*}} Function{{.*}} '__arithmetic_fence' 'void ()'
69