// Tests without serialization:
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu %s \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu -fnative-half-type %s \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
//
// Tests with serialization:
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --strict-whitespace
//
// RUN: %clang_cc1 -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++11 -triple aarch64-linux-gnu -fnative-half-type -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
/* Various contexts where type _Float16 can appear. */
/* Namespace */
//CHECK: |-NamespaceDecl
//CHECK-NEXT: | |-VarDecl {{.*}} f1n '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '_Float16' cinit
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 3.300000e+01
//CHECK-NEXT: | |-VarDecl {{.*}} arr1n '_Float16[10]'
//CHECK-NEXT: | |-VarDecl {{.*}} arr2n '_Float16[3]' cinit
//CHECK-NEXT: | | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: | `-FunctionDecl {{.*}} func1n 'const volatile _Float16 (const _Float16 &)'
/* File */
_Float16 f1f;
_Float16 f2f = 32.4;
_Float16 arr1f;
_Float16 arr2f = ;
_Float16 ;
//CHECK: |-VarDecl {{.*}} f1f '_Float16'
//CHECK-NEXT: |-VarDecl {{.*}} f2f '_Float16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.240000e+01
//CHECK-NEXT: |-VarDecl {{.*}} arr1f '_Float16[10]'
//CHECK-NEXT: |-VarDecl {{.*}} arr2f '_Float16[3]' cinit
//CHECK-NEXT: | `-InitListExpr {{.*}} '_Float16[3]'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 1.200000e+00
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} 'double' 3.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Float16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 3.000000e+04
//CHECK-NEXT: |-FunctionDecl {{.*}} func1f '_Float16 (_Float16)'
//CHECK-NEXT: | `-ParmVarDecl {{.*}} arg '_Float16'
// Mixing __fp16 and Float16 types:
// The _Float16 type is first converted to __fp16 type and then the operation
// is completed as if both operands were of __fp16 type.
__fp16 B = -0.1;
auto C = -1.0f16 + B;
// When we do *not* have native half types, we expect __fp16 to be promoted to
// float, and consequently also _Float16 promotions to float:
//CHECK: -VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NEXT: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NEXT: |-VarDecl {{.*}} C 'float':'float' cinit
//CHECK-NEXT: | `-BinaryOperator {{.*}} 'float' '+'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'float' <FloatingCast>
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
// When do have native half types, we expect to see promotions to fp16:
//CHECK-NATIVE: |-VarDecl {{.*}} used B '__fp16' cinit
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | `-UnaryOperator {{.*}} 'double' prefix '-'
//CHECK-NATIVE: | `-FloatingLiteral {{.*}} 'double' 1.000000e-01
//CHECK-NATIVE: |-VarDecl {{.*}} C '__fp16':'__fp16' cinit
//CHECK-NATIVE: | `-BinaryOperator {{.*}} '__fp16' '+'
//CHECK-NATIVE: | |-ImplicitCastExpr {{.*}} '__fp16' <FloatingCast>
//CHECK-NATIVE: | | `-UnaryOperator {{.*}} '_Float16' prefix '-'
//CHECK-NATIVE: | | `-FloatingLiteral {{.*}} '_Float16' 1.000000e+00
//CHECK-NATIVE: | `-ImplicitCastExpr {{.*}} '__fp16' <LValueToRValue>
//CHECK-NATIVE: | `-DeclRefExpr {{.*}} '__fp16' lvalue Var 0x{{.*}} 'B' '__fp16'
/* Class */
;
//CHECK: |-CXXRecordDecl {{.*}} referenced class C1 definition
//CHECK: | |-CXXRecordDecl {{.*}} implicit referenced class C1
//CHECK-NEXT: | |-FieldDecl {{.*}} referenced f1c '_Float16'
//CHECK-NEXT: | |-VarDecl {{.*}} used f2c 'const _Float16' static
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile _Float16'
//CHECK-NEXT: | |-AccessSpecDecl
//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} used C1 'void (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f1c' '_Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f3c' 'volatile _Float16'
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func1c '_Float16 (_Float16)
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
//CHECK-NEXT: | | | `-CXXThisExpr {{.*}} 'C1 *' implicit this
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'const _Float16' lvalue Var 0x{{.*}} 'f2c' 'const _Float16'
/* Template */
C
//CHECK: |-FunctionTemplateDecl {{.*}} func1t
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} C
//CHECK-NEXT: | |-FunctionDecl {{.*}} func1t 'C (C)'
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} referenced arg 'C'
//CHECK-NEXT: | | `-CompoundStmt
//CHECK-NEXT: | | `-ReturnStmt
//CHECK-NEXT: | | `-BinaryOperator {{.*}} '<dependent type>' '*'
//CHECK-NEXT: | | |-DeclRefExpr {{.*}} 'C' lvalue ParmVar {{.*}} 'arg' 'C'
//CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
//CHECK-NEXT: | `-FunctionDecl {{.*}} used func1t '_Float16 (_Float16)'
//CHECK-NEXT: | |-TemplateArgument type '_Float16'
//CHECK: | |-ParmVarDecl {{.*}} used arg '_Float16':'_Float16'
//CHECK-NEXT: | `-CompoundStmt
//CHECK-NEXT: | `-ReturnStmt
//CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '*'
//CHECK-NEXT: | |-ImplicitCastExpr {{.*}} '_Float16':'_Float16' <LValueToRValue>
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16':'_Float16' lvalue ParmVar {{.*}} 'arg' '_Float16':'_Float16'
//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00
;
//CHECK: |-ClassTemplateDecl {{.*}} S1
//CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 C
//CHECK-NEXT: | |-CXXRecordDecl {{.*}} struct S1 definition
//CHECK: | | |-CXXRecordDecl {{.*}} implicit struct S1
//CHECK-NEXT: | | `-FieldDecl {{.*}} mem1 'C'
//CHECK-NEXT: | `-ClassTemplateSpecialization {{.*}} 'S1'
;
/* Local */
extern int ;
int