Skip to content

Commit c5650ed

Browse files
committed
new tests
1 parent 2885875 commit c5650ed

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify
2+
3+
export void cantCast() {
4+
int A[3] = {1,2,3};
5+
int B[4] = {1,2,3,4};
6+
B = (int[4])A;
7+
// expected-error@-1 {{C-style cast from 'int *' to 'int[4]' is not allowed}}
8+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -fnative-half-type %s -ast-dump | FileCheck %s
2+
3+
// truncation
4+
// CHECK-LABEL: call1
5+
// CHECK: CStyleCastExpr {{.*}} 'int[1]' <HLSLAggregateCast>
6+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int[2]' <HLSLArrayRValue> part_of_explicit_cast
7+
// CHECK-NEXT: DeclRefExpr {{.*}} 'int[2]' lvalue Var {{.*}} 'A' 'int[2]'
8+
export 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 size
15+
// CHECK-LABEL: call2
16+
// CHECK: CStyleCastExpr {{.*}} 'float[1]' <HLSLAggregateCast>
17+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int[1]' <HLSLArrayRValue> part_of_explicit_cast
18+
// CHECK-NEXT: DeclRefExpr {{.*}} 'int[1]' lvalue Var {{.*}} 'A' 'int[1]'
19+
export void call2() {
20+
int A[1] = {0};
21+
float B[1] = {1.0};
22+
B = (float[1])A;
23+
}

0 commit comments

Comments
 (0)