1 // Test without serialization:
2 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-linux -std=c++11 -ast-dump %s \
3 // RUN: | FileCheck --strict-whitespace %s
5 // Test with serialization:
6 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -include-pch %t -ast-dump-all /dev/null \
8 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
9 // RUN: | FileCheck --strict-whitespace %s
11 float func_01(float x
);
15 #pragma STDC FP_CONTRACT ON
19 float func_03(float x
) {
20 #pragma STDC FP_CONTRACT OFF
24 // CHECK: FunctionTemplateDecl {{.*}} func_02
25 // CHECK: FunctionDecl {{.*}} func_02 'float (float)'
26 // CHECK-NEXT: TemplateArgument type 'float'
27 // CHECK-NEXT: BuiltinType {{.*}} 'float'
28 // CHECK-NEXT: ParmVarDecl {{.*}} x 'float'
29 // CHECK-NEXT: CompoundStmt
30 // CHECK-NEXT: ReturnStmt
31 // CHECK-NEXT: CallExpr {{.*}} FPContractMode=1
33 // CHECK: FunctionDecl {{.*}} func_03 'float (float)'
34 // CHECK-NEXT: ParmVarDecl {{.*}} x 'float'
35 // CHECK-NEXT: CompoundStmt
36 // CHECK-NEXT: ReturnStmt
37 // CHECK-NEXT: CallExpr {{.*}} FPContractMode=0
39 int func_04(float x
) {
40 #pragma STDC FP_CONTRACT ON
44 // CHECK: FunctionDecl {{.*}} func_04 'int (float)'
45 // CHECK-NEXT: ParmVarDecl {{.*}} x 'float'
46 // CHECK-NEXT: CompoundStmt
47 // CHECK-NEXT: ReturnStmt
48 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <FloatingToIntegral> FPContractMode=1
50 float func_05(double x
) {
51 #pragma STDC FP_CONTRACT ON
55 // CHECK: FunctionDecl {{.*}} func_05 'float (double)'
56 // CHECK-NEXT: ParmVarDecl {{.*}} x 'double'
57 // CHECK-NEXT: CompoundStmt
58 // CHECK-NEXT: ReturnStmt
59 // CHECK-NEXT: CStyleCastExpr {{.*}} FPContractMode=1
61 float func_06(double x
) {
62 #pragma STDC FP_CONTRACT ON
66 // CHECK: FunctionDecl {{.*}} func_06 'float (double)'
67 // CHECK-NEXT: ParmVarDecl {{.*}} x 'double'
68 // CHECK-NEXT: CompoundStmt
69 // CHECK-NEXT: ReturnStmt
70 // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} FPContractMode=1
72 float func_07(double x
) {
73 #pragma STDC FP_CONTRACT ON
74 return static_cast<float>(x
);
77 // CHECK: FunctionDecl {{.*}} func_07 'float (double)'
78 // CHECK-NEXT: ParmVarDecl {{.*}} x 'double'
79 // CHECK-NEXT: CompoundStmt
80 // CHECK-NEXT: ReturnStmt
81 // CHECK-NEXT: CXXStaticCastExpr {{.*}} FPContractMode=1
83 #pragma STDC FENV_ROUND FE_DOWNWARD
85 float func_10(float x
, float y
) {
89 // CHECK-LABEL: FunctionDecl {{.*}} func_10 'float (float, float)'
90 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=downward
92 float func_11(float x
, float y
) {
94 #pragma STDC FENV_ROUND FE_UPWARD
100 // CHECK-LABEL: FunctionDecl {{.*}} func_11 'float (float, float)'
101 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=upward
102 // CHECK: BinaryOperator {{.*}} 'float' '-' ConstRoundingMode=downward
105 #pragma STDC FENV_ROUND FE_DYNAMIC
107 float func_12(float x
, float y
) {
111 // CHECK-LABEL: FunctionDecl {{.*}} func_12 'float (float, float)'
112 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=dynamic
114 #pragma STDC FENV_ROUND FE_TONEAREST
116 float func_13(float x
, float y
) {
120 // CHECK-LABEL: FunctionDecl {{.*}} func_13 'float (float, float)'
121 // CHECK: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=tonearest
124 template <typename T
>
125 T
func_14(T x
, T y
) {
126 #pragma STDC FENV_ROUND FE_TOWARDZERO
130 float func_15(float x
, float y
) {
131 #pragma STDC FENV_ROUND FE_DOWNWARD
132 return func_14(x
, y
);
135 // CHECK-LABEL: FunctionTemplateDecl {{.*}} func_14
136 // CHECK: FunctionDecl {{.*}} func_14 'T (T, T)'
137 // CHECK: CompoundStmt
138 // CHECK-NEXT: ReturnStmt
139 // CHECK-NEXT: BinaryOperator {{.*}} '+' ConstRoundingMode=towardzero
140 // CHECK: FunctionDecl {{.*}} func_14 'float (float, float)'
141 // CHECK: CompoundStmt
142 // CHECK-NEXT: ReturnStmt
143 // CHECK-NEXT: BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=towardzero
145 float func_16(float x
, float y
) {
146 #pragma STDC FENV_ROUND FE_TOWARDZERO
148 #pragma STDC FENV_ROUND FE_UPWARD
154 // CHECK-LABEL: FunctionDecl {{.*}} func_16 'float (float, float)'
155 // CHECK: CompoundStmt {{.*}} ConstRoundingMode=towardzero
157 // CHECK: CompoundStmt {{.*}} ConstRoundingMode=upward
159 // CHECK: BinaryOperator {{.*}} ConstRoundingMode=upward
161 // CHECK: BinaryOperator {{.*}} ConstRoundingMode=towardzero
163 float func_17(float x
, float y
) {
164 #pragma STDC FENV_ROUND FE_TOWARDZERO
166 #pragma STDC FENV_ROUND FE_TOWARDZERO
172 // CHECK-LABEL: FunctionDecl {{.*}} func_17 'float (float, float)'
173 // CHECK: CompoundStmt {{.*}} ConstRoundingMode=towardzero
175 // CHECK: CompoundStmt {{.*}}
177 // CHECK: BinaryOperator {{.*}} ConstRoundingMode=towardzero
179 // CHECK: BinaryOperator {{.*}} ConstRoundingMode=towardzero
181 #pragma STDC FENV_ROUND FE_DOWNWARD
182 float func_18(float x
, float y
) {
186 // CHECK-LABEL: FunctionDecl {{.*}} func_18 'float (float, float)'
187 // CHECK: CompoundStmt {{.*}} ConstRoundingMode=downward
189 // CHECK: BinaryOperator {{.*}} ConstRoundingMode=downward