File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -2710,6 +2710,9 @@ bool SemaHLSL::CheckCompatibleParameterABI(FunctionDecl *New,
2710
2710
// clarity of what types are supported
2711
2711
bool SemaHLSL::CanPerformScalarCast (QualType SrcTy, QualType DestTy) {
2712
2712
2713
+ if (!SrcTy->isScalarType () || !DestTy->isScalarType ())
2714
+ return false ;
2715
+
2713
2716
if (SemaRef.getASTContext ().hasSameUnqualifiedType (SrcTy, DestTy))
2714
2717
return true ;
2715
2718
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
1
+ // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify -verify-ignore-unexpected=note
2
2
3
3
struct S {
4
- // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const S' for 1st argument}}
5
- // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'S' for 1st argument}}
6
- // expected-note@-3 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
7
4
int A : 8 ;
8
5
int B;
9
6
};
10
7
11
8
struct R {
12
- // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const R' for 1st argument}}
13
- // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'R' for 1st argument}}
14
- // expected-note@-3 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
15
9
int A;
16
10
union {
17
11
float F;
@@ -30,3 +24,26 @@ export void cantCast2() {
30
24
R r = (R)1 ;
31
25
// expected-error@-1 {{no matching conversion for C-style cast from 'int' to 'R'}}
32
26
}
27
+
28
+ RWBuffer <float4 > Buf;
29
+
30
+ // Can't cast an intangible type
31
+ export void cantCast3 () {
32
+ Buf = (RWBuffer <float4 >)1 ;
33
+ // expected-error@-1 {{no matching conversion for C-style cast from 'int' to 'RWBuffer<float4>' (aka 'RWBuffer<vector<float, 4>>')}}
34
+ }
35
+
36
+ export void cantCast4 () {
37
+ RWBuffer <float4 > B[2 ] = (RWBuffer <float4 >[2 ])1 ;
38
+ // expected-error@-1 {{C-style cast from 'int' to 'RWBuffer<float4>[2]' (aka 'RWBuffer<vector<float, 4>>[2]') is not allowed}}
39
+ }
40
+
41
+ struct X {
42
+ int A;
43
+ RWBuffer <float4 > Buf;
44
+ };
45
+
46
+ export void cantCast5 () {
47
+ X x = (X)1 ;
48
+ // expected-error@-1 {{no matching conversion for C-style cast from 'int' to 'X'}}
49
+ }
You can’t perform that action at this time.
0 commit comments