Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2210,8 +2210,10 @@ bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) {
llvm::SmallVector<QualType, 4> QTTypes;
BuildFlattenedTypeList(QT, QTTypes);

assert(QTTypes.size() > 0 &&
"expected at least one constituent type from non-null type");
// empty structs are not typed resource element compatible
if (QTTypes.size() == 0)
return false;

QualType FirstQT = SemaRef.Context.getCanonicalType(QTTypes[0]);

// element count cannot exceed 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,14 @@ struct TypeDefTest {
};

_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(TypeDefTest), "");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove all these tests, or just update them to expect false results?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could be left in and switched to false, but it doesn't seem valuable. All structs are disallowed, so I think just one struct test would suffice.


struct EmptyStruct {};
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyStruct), "");

struct EmptyDerived : EmptyStruct {};
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyDerived), "");

struct EmptyBase : EmptyStruct {
int4 V;
};
_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(EmptyBase), "");
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(__hlsl_resour
struct notComplete;
// expected-error@+1{{incomplete type 'notComplete' where a complete type is required}}
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(notComplete), "");

Loading