Skip to content

Commit 6e218c5

Browse files
committed
address Chris
1 parent 010785c commit 6e218c5

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5718,7 +5718,7 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
57185718

57195719
case UTT_IsTypedResourceElementCompatible:
57205720
assert(Self.getLangOpts().HLSL &&
5721-
"line vector layout compatible types are HLSL-only feature");
5721+
"typed resource element compatible types are an HLSL-only feature");
57225722
if (Self.RequireCompleteType(TInfo->getTypeLoc().getBeginLoc(), T,
57235723
diag::err_incomplete_type))
57245724
return false;

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,25 +2176,25 @@ bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) {
21762176

21772177
assert(QTTypes.size() > 0 &&
21782178
"expected at least one constituent type from non-null type");
2179-
QualType FirstQT = QTTypes[0];
2179+
QualType FirstQT = SemaRef.Context.getCanonicalType(QTTypes[0]);
21802180

21812181
// element count cannot exceed 4
21822182
if (QTTypes.size() > 4)
21832183
return false;
21842184

21852185
for (QualType TempQT : QTTypes) {
21862186
// ensure homogeneity
2187-
if (TempQT != FirstQT)
2187+
if (!getASTContext().hasSameUnqualifiedType(FirstQT, TempQT))
21882188
return false;
2189+
}
21892190

2190-
if (const BuiltinType *BT = TempQT->getAs<BuiltinType>()) {
2191-
if (BT->isBooleanType() || BT->isEnumeralType())
2192-
return false;
2191+
if (const BuiltinType *BT = FirstQT->getAs<BuiltinType>()) {
2192+
if (BT->isBooleanType() || BT->isEnumeralType())
2193+
return false;
21932194

2194-
// Check if it is an array type.
2195-
if (TempQT->isArrayType())
2196-
return false;
2197-
}
2195+
// Check if it is an array type.
2196+
if (FirstQT->isArrayType())
2197+
return false;
21982198
}
21992199

22002200
// if the loop above completes without returning, then

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,11 @@ _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(SimpleTemplat
9999
_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(SimpleTemplate<float>), "");
100100

101101

102+
typedef int myInt;
103+
104+
struct TypeDefTest {
105+
int x;
106+
myInt y;
107+
};
108+
109+
_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(TypeDefTest), "");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(__hlsl_resour
77
struct notComplete;
88
// expected-error@+1{{incomplete type 'notComplete' where a complete type is required}}
99
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(notComplete), "");
10-
10+

0 commit comments

Comments
 (0)