diff options
| author | Tim Foley <tim.foley.is@gmail.com> | 2017-08-15 11:09:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-15 11:09:03 -0700 |
| commit | e6abc6821a1bf13a9826e7db74362ce34ccaca2a (patch) | |
| tree | 34d2ad3937c3986dfa7ce8d660cf902c19315581 /source/slang/parameter-binding.cpp | |
| parent | 4a9b281c154422cdef03ef629718a458f753093f (diff) | |
| parent | f64bbf712e4e0719604d1e6728eef74539c9ceda (diff) | |
Merge pull request #162 from tfoleyNV/gh-38
Improve diagnostics for overlapping/conflicting bindings
Diffstat (limited to 'source/slang/parameter-binding.cpp')
| -rw-r--r-- | source/slang/parameter-binding.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index 757662101..a00520c05 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -735,6 +735,7 @@ static RefPtr<UsedRangeSet> findUsedRangeSetForTranslationUnit( static void addExplicitParameterBinding( ParameterBindingContext* context, RefPtr<ParameterInfo> parameterInfo, + VarDeclBase* varDecl, LayoutSemanticInfo const& semanticInfo, UInt count, RefPtr<UsedRangeSet> usedRangeSet = nullptr) @@ -751,8 +752,13 @@ static void addExplicitParameterBinding( || bindingInfo.index != semanticInfo.index || bindingInfo.space != semanticInfo.space ) { + getSink(context)->diagnose(varDecl, Diagnostics::conflictingExplicitBindingsForParameter, getReflectionName(varDecl)); + auto firstVarDecl = parameterInfo->varLayouts[0]->varDecl.getDecl(); - getSink(context)->diagnose(firstVarDecl, Diagnostics::conflictingExplicitBindingsForParameter, getReflectionName(firstVarDecl)); + if( firstVarDecl != varDecl ) + { + getSink(context)->diagnose(firstVarDecl, Diagnostics::seeOtherDeclarationOf, getReflectionName(firstVarDecl)); + } } // TODO(tfoley): `register` semantics can technically be @@ -781,6 +787,8 @@ static void addExplicitParameterBinding( getSink(context)->diagnose(paramA, Diagnostics::parameterBindingsOverlap, getReflectionName(paramA), getReflectionName(paramB)); + + getSink(context)->diagnose(paramB, Diagnostics::seeDeclarationOf, getReflectionName(paramB)); } } } @@ -822,7 +830,7 @@ static void addExplicitParameterBindings_HLSL( // TODO: warning here! } - addExplicitParameterBinding(context, parameterInfo, semanticInfo, count); + addExplicitParameterBinding(context, parameterInfo, varDecl, semanticInfo, count); } } @@ -888,7 +896,7 @@ static void addExplicitParameterBindings_GLSL( auto count = resInfo->count; semanticInfo.kind = kind; - addExplicitParameterBinding(context, parameterInfo, semanticInfo, int(count), usedRangeSet); + addExplicitParameterBinding(context, parameterInfo, varDecl, semanticInfo, int(count), usedRangeSet); } // Given a single parameter, collect whatever information we have on |
