48 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -fnative-half-type %s -ast-dump | FileCheck %s2 3// truncation4// CHECK-LABEL: call15// CHECK: CStyleCastExpr {{.*}} 'int[1]' <HLSLElementwiseCast>6// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int[2]' <HLSLArrayRValue> part_of_explicit_cast7// CHECK-NEXT: DeclRefExpr {{.*}} 'int[2]' lvalue Var {{.*}} 'A' 'int[2]'8export void call1() {9 int A[2] = {0,1};10 int B[1] = {4};11 B = (int[1])A;12}13 14// flat cast of equal size15// CHECK-LABEL: call216// CHECK: CStyleCastExpr {{.*}} 'float[1]' <HLSLElementwiseCast>17// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int[1]' <HLSLArrayRValue> part_of_explicit_cast18// CHECK-NEXT: DeclRefExpr {{.*}} 'int[1]' lvalue Var {{.*}} 'A' 'int[1]'19export void call2() {20 int A[1] = {0};21 float B[1] = {1.0};22 B = (float[1])A;23}24 25struct S {26 int A;27 float F;28};29 30// cast from a struct31// CHECK-LABEL: call332// CHECK: CStyleCastExpr {{.*}} 'int[2]' <HLSLElementwiseCast>33// CHECK-NEXT: DeclRefExpr {{.*}} 'S' lvalue Var {{.*}} 'SS' 'S'34export void call3() {35 S SS = {1,1.0};36 int A[2] = (int[2])SS;37}38 39// cast from a vector40// CHECK-LABEL: call441// CHECK: CStyleCastExpr {{.*}} 'float[3]' <HLSLElementwiseCast>42// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int3':'vector<int, 3>' <LValueToRValue> part_of_explicit_cast43// CHECK-NEXT: DeclRefExpr {{.*}} 'int3':'vector<int, 3>' lvalue Var {{.*}} 'A' 'int3'44export void call4() {45 int3 A = {1,2,3};46 float B[3] = (float[3])A;47}48