Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 16 additions & 16 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6750,6 +6750,22 @@ bool HLSLExternalSource::MatchArguments(
return false;
}

ASTContext &actx = m_sema->getASTContext();
// Usage

// Argument must be non-constant and non-bitfield for out, inout, and ref
// parameters because they may be treated as pass-by-reference.
// This is hacky. We should actually be handling this by failing reference
// binding in sema init with SK_BindReference*. That code path is currently
// hacked off for HLSL and less trivial to fix.
if (pIntrinsicArg->qwUsage & AR_QUAL_OUT ||
pIntrinsicArg->qwUsage & AR_QUAL_REF) {
if (pType.isConstant(actx) || pCallArg->getObjectKind() == OK_BitField) {
// Can't use a const type in an out or inout parameter.
badArgIdx = std::min(badArgIdx, iArg);
}
}

if (pIntrinsicArg->uLegalComponentTypes == LICOMPTYPE_USER_DEFINED_TYPE) {
DXASSERT_NOMSG(objectElement.isNull());
QualType Ty = pCallArg->getType();
Expand Down Expand Up @@ -6902,22 +6918,6 @@ bool HLSLExternalSource::MatchArguments(
}
}
}

ASTContext &actx = m_sema->getASTContext();
// Usage

// Argument must be non-constant and non-bitfield for out, inout, and ref
// parameters because they may be treated as pass-by-reference.
// This is hacky. We should actually be handling this by failing reference
// binding in sema init with SK_BindReference*. That code path is currently
// hacked off for HLSL and less trivial to fix.
if (pIntrinsicArg->qwUsage & AR_QUAL_OUT ||
pIntrinsicArg->qwUsage & AR_QUAL_REF) {
if (pType.isConstant(actx) || pCallArg->getObjectKind() == OK_BitField) {
// Can't use a const type in an out or inout parameter.
badArgIdx = std::min(badArgIdx, iArg);
}
}
iArg++;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %dxc -T lib_6_9 %s -verify

struct Payload {
float value : write(caller) : read(caller);
};

[shader("raygeneration")]
void RayGen()
{
RayDesc ray;
const Payload p = {0.0};
dx::HitObject obj = dx::HitObject::MakeMiss(0, 0, ray);
dx::HitObject::Invoke(obj, p); // expected-error{{no matching function for call to 'Invoke'}}
}