diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-08-15 09:29:52 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-08-15 09:33:36 -0700 |
| commit | 4a94f39020dcc143f9a1d8f5c57ba77a828ead61 (patch) | |
| tree | 384ed2dd18f2d3fa070dffbd70d3e1f9a2bf0909 /source/slang/parameter-binding.cpp | |
| parent | 4a9b281c154422cdef03ef629718a458f753093f (diff) | |
Improve diagnostics for overlapping/conflicting bindings
Closes #38
- Change overlapping bindings case from error to warning (it is *technically* allowed in HLSL/GLSL)
- Make diagnostic messages for these cases include a note to point at the "other" declaration in each case, so that user can more easily isolate the problem
- Unrelated fix: make sure `slangc` sets up its diagnostic callback *before* parsing command-line options so that error messages output during options parsing will be visible
- Unrelated fix: make sure that formatting for diagnostic messages doesn't print diagnostic ID for notes (all have IDs < 0).
- Note: eventually I'd like to not print diagnostic IDs at all (I think they are cluttering up our output), but doing that requires touching all the test cases...
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 |
