File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
clang/test/SemaHLSL/Language Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments