diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 13 | ||||
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 5 | ||||
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 16 |
3 files changed, 28 insertions, 6 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 9fd5c8b6e..c3d2efaac 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -22665,7 +22665,7 @@ struct ConstBufferPointer<T, int alignment = 16> [ForceInline] static ConstBufferPointer<T> fromUInt(uint64_t val) { - return {(T*)val}; + return ConstBufferPointer<T>(val); } [ForceInline] @@ -22679,8 +22679,17 @@ struct ConstBufferPointer<T, int alignment = 16> { return _ptr != nullptr; } -} + __init(T* val) + { + _ptr = val; + } + + __init(uint64_t val) + { + _ptr = (T*)val; + } +} // // HLSL-like dynamic resources // https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_DynamicResources.html diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index 61d132627..a605928e3 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -1711,6 +1711,8 @@ bool SemanticsVisitor::_coerce( } } + bool result = true; + // Conceptually, we want to treat the conversion as // possible, but report it as ambiguous if we actually // need to reify the result as an expression. @@ -1723,6 +1725,7 @@ bool SemanticsVisitor::_coerce( } *outToExpr = CreateErrorExpr(fromExpr); + result = false; } if (!cachedMethod) @@ -1734,7 +1737,7 @@ bool SemanticsVisitor::_coerce( if (outCost) *outCost = bestCost; - return true; + return result; } else if (overloadContext.bestCandidate) { diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 71e8488d8..9e5560b3a 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -2727,6 +2727,7 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr) // bool typeOverloadChecked = false; + DiagnosticSink collectedErrorsSink(getSourceManager(), nullptr); if (expr->arguments.getCount() == 1 && !as<ExplicitCtorInvokeExpr>(expr) && !as<InitializerListExpr>(expr->arguments[0])) { @@ -2735,16 +2736,15 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr) if (isDeclRefTypeOf<AggTypeDeclBase>(typeType->getType())) { Expr* resultExpr = nullptr; - DiagnosticSink tempSink(getSourceManager(), nullptr); ConversionCost conversionCost = kConversionCost_None; - auto coerceResult = SemanticsVisitor(withSink(&tempSink)) + auto coerceResult = SemanticsVisitor(withSink(&collectedErrorsSink)) ._coerce( CoercionSite::ExplicitCoercion, typeType->getType(), &resultExpr, expr->arguments[0]->type, expr->arguments[0], - &tempSink, + &collectedErrorsSink, &conversionCost); if (auto resultInvokeExpr = as<InvokeExpr>(resultExpr)) { @@ -2963,6 +2963,16 @@ Expr* SemanticsVisitor::ResolveInvoke(InvokeExpr* expr) // for language server to use. if (IsErrorExpr(outExpr)) { + // Drain our error sink of "saved errors" + if (collectedErrorsSink.getErrorCount()) + { + Slang::ComPtr<ISlangBlob> blob; + collectedErrorsSink.getBlobIfNeeded(blob.writeRef()); + getSink()->diagnoseRaw( + Severity::Error, + static_cast<char const*>(blob->getBufferPointer())); + } + if (auto invokeExpr = as<InvokeExpr>(outExpr)) { invokeExpr->originalFunctionExpr = typeExpr; |
