Skip to content

Commit b3b8afb

Browse files
committed
add bool and enum cases, including vector of bools
1 parent 90a73b8 commit b3b8afb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,10 @@ bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) {
22242224
if (ArraySize > 4)
22252225
return false;
22262226

2227+
QualType ElTy = VT->getElementType();
2228+
if (ElTy->isBooleanType())
2229+
return false;
2230+
22272231
if (SemaRef.Context.getTypeSize(QT) / 8 > 16)
22282232
return false;
22292233
return true;

clang/test/SemaHLSL/Types/Traits/IsTypedResourceElementCompatible.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(int8), "");
3939
typedef int MyInt;
4040
_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(MyInt), "");
4141

42+
// bool and enums not allowed
43+
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(bool), "");
44+
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(vector<bool, 2>), "");
45+
46+
enum numbers { one, two, three };
47+
48+
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(numbers), "");
49+
4250
// size exceeds 16 bytes, and exceeds element count limit after splitting 64 bit types into 32 bit types
4351
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(double3), "");
4452

0 commit comments

Comments
 (0)