diff options
31 files changed, 205 insertions, 87 deletions
diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index f360d3cc6..197e9bb64 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -75,7 +75,7 @@ SourceLoc getDiagnosticPos(Token const& token) } // Take the format string for a diagnostic message, along with its arguments, and turn it into a -static void formatDiagnosticMessage(StringBuilder& sb, char const* format, int argCount, DiagnosticArg const* const* args) +static void formatDiagnosticMessage(StringBuilder& sb, char const* format, int argCount, DiagnosticArg const* args) { char const* spanBegin = format; for(;;) @@ -116,8 +116,8 @@ static void formatDiagnosticMessage(StringBuilder& sb, char const* format, int a } else { - DiagnosticArg const* arg = args[index]; - arg->printFunc(sb, arg->data); + DiagnosticArg const& arg = args[index]; + arg.printFunc(sb, arg.data); } } break; @@ -459,9 +459,7 @@ static void formatDiagnostic( _tokenLengthNoteDiagnostic(sink, sourceView, sourceLoc, sb); } - // We don't don't output source line information if this is a 'note' as a note is extra information for one - // of the other main severity types, and so the information should already be output on the initial line - if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::SourceLocationLine) && diagnostic.severity != Severity::Note) + if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::SourceLocationLine) && diagnostic.loc.isValid()) { _sourceLocationNoteDiagnostic(sink, sourceView, sourceLoc, sb); } @@ -600,7 +598,7 @@ Severity DiagnosticSink::getEffectiveMessageSeverity(DiagnosticInfo const& info) return effectiveSeverity; } -void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* const* args) +void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args) { // Override the severity in the 'info' structure to pass it further into formatDiagnostics info.severity = getEffectiveMessageSeverity(info); diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h index ebd43b456..c150de900 100644 --- a/source/compiler-core/slang-diagnostic-sink.h +++ b/source/compiler-core/slang-diagnostic-sink.h @@ -162,39 +162,31 @@ public: /// Get the total amount of errors that have taken place on this DiagnosticSink SLANG_FORCE_INLINE int getErrorCount() { return m_errorCount; } - void diagnoseDispatch(SourceLoc const& pos, DiagnosticInfo const& info) - { - diagnoseImpl(pos, info, 0, nullptr); - } - - void diagnoseDispatch(SourceLoc const& pos, DiagnosticInfo const& info, DiagnosticArg const& arg0) + template<typename P, typename... Args> + void diagnose(P const& pos, DiagnosticInfo const& info, Args const&... args ) { - DiagnosticArg const* args[] = { &arg0 }; - diagnoseImpl(pos, info, 1, args); + DiagnosticArg as[] = { DiagnosticArg(args)... }; + diagnoseImpl(getDiagnosticPos(pos), info, sizeof...(args), as); } - void diagnoseDispatch(SourceLoc const& pos, DiagnosticInfo const& info, DiagnosticArg const& arg0, DiagnosticArg const& arg1) + template<typename P> + void diagnose(P const& pos, DiagnosticInfo const& info) { - DiagnosticArg const* args[] = { &arg0, &arg1 }; - diagnoseImpl(pos, info, 2, args); + // MSVC gets upset with the zero sized array above, so overload that case here + diagnoseImpl(getDiagnosticPos(pos), info, 0, nullptr); } - void diagnoseDispatch(SourceLoc const& pos, DiagnosticInfo const& info, DiagnosticArg const& arg0, DiagnosticArg const& arg1, DiagnosticArg const& arg2) + // Useful for notes on existing diagnostics, where it would be redundant to display the same line again. + // (Ideally we would print the error/warning and notes in one call...) + template<typename P, typename... Args> + void diagnoseWithoutSourceView(P const& pos, DiagnosticInfo const& info, Args const&... args ) { - DiagnosticArg const* args[] = { &arg0, &arg1, &arg2 }; - diagnoseImpl(pos, info, 3, args); - } + const auto fs = this->getFlags(); + this->resetFlag(Flag::SourceLocationLine); - void diagnoseDispatch(SourceLoc const& pos, DiagnosticInfo const& info, DiagnosticArg const& arg0, DiagnosticArg const& arg1, DiagnosticArg const& arg2, DiagnosticArg const& arg3) - { - DiagnosticArg const* args[] = { &arg0, &arg1, &arg2, &arg3 }; - diagnoseImpl(pos, info, 4, args); - } + diagnose(pos, info, args...); - template<typename P, typename... Args> - void diagnose(P const& pos, DiagnosticInfo const& info, Args const&... args ) - { - diagnoseDispatch(getDiagnosticPos(pos), info, args...); + this->setFlags(fs); } // Add a diagnostic with raw text @@ -267,7 +259,7 @@ public: ISlangWriter* writer = nullptr; protected: - void diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* const* args); + void diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args); void diagnoseImpl(DiagnosticInfo const& info, const UnownedStringSlice& formattedMessage); Severity getEffectiveMessageSeverity(DiagnosticInfo const& info); diff --git a/source/slang/slang-ast-decl.cpp b/source/slang/slang-ast-decl.cpp index 261378b9a..2f1c7c47e 100644 --- a/source/slang/slang-ast-decl.cpp +++ b/source/slang/slang-ast-decl.cpp @@ -102,4 +102,20 @@ void ContainerDecl::buildMemberDictionary() SLANG_ASSERT(isMemberDictionaryValid()); } +bool isLocalVar(const Decl* decl) +{ + const auto varDecl = as<VarDecl>(decl); + if(!varDecl) + return false; + const Decl* pp = varDecl->parentDecl; + if(as<ScopeDecl>(pp)) + return true; + while(auto genericDecl = as<GenericDecl>(pp)) + pp = genericDecl->inner; + if(as<FunctionDeclBase>(pp)) + return true; + + return false; +} + } // namespace Slang diff --git a/source/slang/slang-ast-decl.h b/source/slang/slang-ast-decl.h index e75660c7b..93e5a19ad 100644 --- a/source/slang/slang-ast-decl.h +++ b/source/slang/slang-ast-decl.h @@ -552,4 +552,6 @@ class BackwardDerivativeRequirementDecl : public DerivativeRequirementDecl bool isInterfaceRequirement(Decl* decl); InterfaceDecl* findParentInterfaceDecl(Decl* decl); +bool isLocalVar(const Decl* decl); + } // namespace Slang diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h index b6e98bbd4..d3cb4e55d 100644 --- a/source/slang/slang-ast-support-types.h +++ b/source/slang/slang-ast-support-types.h @@ -21,6 +21,7 @@ #include "slang-ref-object-reflect.h" #include <assert.h> +#include <type_traits> namespace Slang { @@ -1181,7 +1182,17 @@ namespace Slang IgnoreBaseInterfaces = 1 << 0, Completion = 1 << 1, ///< Lookup all applicable decls for code completion suggestions NoDeref = 1 << 2, + ConsiderAllLocalNamesInScope = 1 << 3, + ///^ Normally we rely on the checking state of local names to determine + /// if they have been declared. If the scopes are currently + /// "under-construction" and not being checked, then it's safe to + /// consider all names we've inserted so far. This is used when + /// checking to see if a keyword is shadowed. }; + inline LookupOptions operator&(LookupOptions a, LookupOptions b) + { + return (LookupOptions)((std::underlying_type_t<LookupOptions>)a & (std::underlying_type_t<LookupOptions>)b); + } class SerialRefObject; @@ -1421,7 +1432,8 @@ namespace Slang LookupMask mask = LookupMask::Default; LookupOptions options = LookupOptions::None; - bool isCompletionRequest() const { return ((int)options & (int)LookupOptions::Completion) != 0; } + bool isCompletionRequest() const { return (options & LookupOptions::Completion) != LookupOptions::None; } + bool shouldConsiderAllLocalNames() const { return (options & LookupOptions::ConsiderAllLocalNamesInScope) != LookupOptions::None; } }; struct WitnessTable; diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index 1afbaf6e8..17b55a2cb 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -1115,7 +1115,7 @@ namespace Slang if (cost >= kConversionCost_Explicit) { getSink()->diagnose(fromExpr, Diagnostics::typeMismatch, toType, fromType); - getSink()->diagnose( + getSink()->diagnoseWithoutSourceView( fromExpr, Diagnostics::noteExplicitConversionPossible, fromType, toType); } else if (cost >= kConversionCost_Default) diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index e2d6b797a..46b968279 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -395,20 +395,12 @@ namespace Slang return true; } - static bool _isLocalVar(VarDeclBase* varDecl) + [[maybe_unused]] + static bool _isUncheckedLocalVar(const Decl* decl) { - auto pp = varDecl->parentDecl; - - if(as<ScopeDecl>(pp)) - return true; - - if(auto genericDecl = as<GenericDecl>(pp)) - pp = genericDecl; - - if(as<FuncDecl>(pp)) - return true; - - return false; + auto checkStateExt = decl->checkState; + auto isUnchecked = checkStateExt.getState() == DeclCheckState::Unchecked || checkStateExt.isBeingChecked(); + return isUnchecked && isLocalVar(decl); } // Get the type to use when referencing a declaration @@ -422,35 +414,12 @@ namespace Slang { if( sema ) { - // Hack: if we are somehow referencing a local variable declaration - // before the line of code that defines it, then we need to diagnose - // an error. - // - // TODO: The right answer is that lookup should have been performed in - // the scope that was in place *before* the variable was declared, but - // this is a quick fix that at least alerts the user to how we are - // interpreting their code. - // - // We detect the problematic case by looking for an attempt to reference - // a local variable declaration when it is unchecked, or in the process - // of being checked (the latter case catches a local variable that refers - // to itself in its initial-value expression). - // - auto checkStateExt = declRef.getDecl()->checkState; - if( checkStateExt.getState() == DeclCheckState::Unchecked - || checkStateExt.isBeingChecked() ) - { - if(auto varDecl = as<VarDecl>(declRef.getDecl())) - { - if(_isLocalVar(varDecl)) - { - sema->getSink()->diagnose(varDecl, Diagnostics::localVariableUsedBeforeDeclared, varDecl); - return QualType(astBuilder->getErrorType()); - } - } - } + // If this is a local variable which hasn't been checked yet then + // it's probably a declare-after-use which has incorrectly got + // through declref resolution. + SLANG_ASSERT(!_isUncheckedLocalVar(declRef.getDecl())); - // Once we've rules out the case of referencing a local declaration + // Once we've ruled out the case of referencing a local declaration // before it has been checked, we will go ahead and ensure that // semantic checking has been performed on the chosen declaration, // at least up to the point where we can query its type. diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index aa3ca889d..11b560d93 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -1909,7 +1909,7 @@ namespace Slang { if(!thisExpr->type.isLeftValue) { - getSink()->diagnose(thisExpr, Diagnostics::thisIsImmutableByDefault); + getSink()->diagnoseWithoutSourceView(thisExpr, Diagnostics::thisIsImmutableByDefault); } } } @@ -2130,7 +2130,7 @@ namespace Slang diagnostic = &Diagnostics::implicitCastUsedAsLValue; } - getSink()->diagnose( + getSink()->diagnoseWithoutSourceView( argExpr, *diagnostic, implicitCastExpr->arguments[pp]->type, diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 922348d61..8f6526d9d 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -41,6 +41,8 @@ DIAGNOSTIC(-1, Note, seeRequirementDeclaration, "see requirement declaration") DIAGNOSTIC(-1, Note, doYouForgetToMakeComponentAccessible, "do you forget to make component '$0' acessible from '$1' (missing public qualifier)?") DIAGNOSTIC(-1, Note, seeDeclarationOf, "see declaration of '$0'") +// An alternate wording of the above note, emphasing the position rather than content of the declaration. +DIAGNOSTIC(-1, Note, declaredHere, "declared here") DIAGNOSTIC(-1, Note, seeOtherDeclarationOf, "see other declaration of '$0'") DIAGNOSTIC(-1, Note, seePreviousDeclarationOf, "see previous declaration of '$0'") DIAGNOSTIC(-1, Note, includeOutput, "include $0") diff --git a/source/slang/slang-ir-witness-table-wrapper.cpp b/source/slang/slang-ir-witness-table-wrapper.cpp index 68fdf5b60..d6cfda808 100644 --- a/source/slang/slang-ir-witness-table-wrapper.cpp +++ b/source/slang/slang-ir-witness-table-wrapper.cpp @@ -190,7 +190,7 @@ namespace Slang if (!sharedContext->doesTypeFitInAnyValue(concreteType, interfaceType, &typeSize, &sizeLimit)) { sharedContext->sink->diagnose(concreteType, Diagnostics::typeDoesNotFitAnyValueSize, concreteType); - sharedContext->sink->diagnose(concreteType, Diagnostics::typeAndLimit, concreteType, typeSize, sizeLimit); + sharedContext->sink->diagnoseWithoutSourceView(concreteType, Diagnostics::typeAndLimit, concreteType, typeSize, sizeLimit); return; } diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp index 0c4279761..46977b71d 100644 --- a/source/slang/slang-lookup.cpp +++ b/source/slang/slang-lookup.cpp @@ -139,6 +139,13 @@ static void _lookUpMembersInValue( LookupResult& ioResult, BreadcrumbInfo* breadcrumbs); +static bool _isUncheckedLocalVar(const Decl* decl) +{ + auto checkStateExt = decl->checkState; + auto isUnchecked = checkStateExt.getState() == DeclCheckState::Unchecked || checkStateExt.isBeingChecked(); + return isUnchecked && isLocalVar(decl); +} + /// Look up direct members (those declared in `containerDeclRef` itself, as well /// as transitively through any direct members that are marked "transparent." /// @@ -162,6 +169,8 @@ static void _lookUpDirectAndTransparentMembers( // return all the members that are available. for (auto member : containerDecl->members) { + if(!request.shouldConsiderAllLocalNames() && _isUncheckedLocalVar(member)) + continue; if (!DeclPassesLookupMask(member, request.mask)) continue; AddToLookupResult( @@ -182,6 +191,12 @@ static void _lookUpDirectAndTransparentMembers( // type declarations. for (auto m = firstDecl; m; m = m->nextInContainerWithSameName) { + // Skip this declaration if we are checking and this hasn't been + // checked yet. Because we traverse block statements in order, if + // it's unchecked or being checked then it isn't declared yet. + if(!request.shouldConsiderAllLocalNames() && _isUncheckedLocalVar(m)) + continue; + if (!DeclPassesLookupMask(m, request.mask)) continue; @@ -948,10 +963,14 @@ LookupResult lookUp( SemanticsVisitor* semantics, Name* name, Scope* scope, - LookupMask mask) + LookupMask mask, + bool considerAllLocalNamesInScope) { LookupResult result; - LookupRequest request = initLookupRequest(semantics, name, mask, LookupOptions::None, scope); + const auto options = considerAllLocalNamesInScope + ? LookupOptions::ConsiderAllLocalNamesInScope + : LookupOptions::None; + LookupRequest request = initLookupRequest(semantics, name, mask, options, scope); _lookUpInScopes(astBuilder, name, request, result); return result; } diff --git a/source/slang/slang-lookup.h b/source/slang/slang-lookup.h index 7a9346498..69374c024 100644 --- a/source/slang/slang-lookup.h +++ b/source/slang/slang-lookup.h @@ -18,7 +18,8 @@ LookupResult lookUp( SemanticsVisitor* semantics, Name* name, Scope* scope, - LookupMask mask = LookupMask::Default); + LookupMask mask = LookupMask::Default, + bool considerAllLocalNamesInScope = false); // Perform member lookup in the context of a type LookupResult lookUpMember( diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 5f9d5fbc4..b8310451c 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -1021,7 +1021,9 @@ namespace Slang parser->astBuilder, nullptr, // no semantics visitor available yet name, - parser->currentScope); + parser->currentScope, + LookupMask::Default, + true); // If we didn't find anything, or the result was overloaded, // then we aren't going to be able to extract a single decl. diff --git a/tests/bugs/generic-type-arg-overloaded.slang.expected b/tests/bugs/generic-type-arg-overloaded.slang.expected index 390c4fe00..1c41da717 100644 --- a/tests/bugs/generic-type-arg-overloaded.slang.expected +++ b/tests/bugs/generic-type-arg-overloaded.slang.expected @@ -4,11 +4,17 @@ tests/bugs/generic-type-arg-overloaded.slang(14): error 30200: declaration of 'S struct Stuff {} ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(11): note: see previous declaration of 'Stuff' +struct Stuff : IThing { int getVal() { return 1; } } + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(26): error 39999: ambiguous reference to 'Stuff' return util<Stuff>() ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(14): note 39999: candidate: struct Stuff +struct Stuff {} + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(11): note 39999: candidate: struct Stuff +struct Stuff : IThing { int getVal() { return 1; } } + ^~~~~ tests/bugs/generic-type-arg-overloaded.slang(32): error 39999: expected a generic when using '<...>' (found: '() -> int') + nonGeneric<G>(); ^~~~~~~~~~ diff --git a/tests/bugs/gh-2936.slang b/tests/bugs/gh-2936.slang new file mode 100644 index 000000000..20bfa1924 --- /dev/null +++ b/tests/bugs/gh-2936.slang @@ -0,0 +1,53 @@ +//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj -output-using-type + +// CHECK: 4 +// CHECK-NEXT: 99 +// CHECK-NEXT: 111 +// CHECK-NEXT: 40 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + outputBuffer[0] = f(); + outputBuffer[1] = g(); + outputBuffer[2] = h(); + outputBuffer[3] = k(30, 40); +} + +static let x = 1; + +func f() -> int +{ + let y = x; // should refer to the global x + let x = 3; + return x + y; // should refer to the local x +} +func g() -> int +{ + // Can we shadow this keyword + int out; + out = 99; + return out; +} + +static var input = 999; +func h() -> int +{ + // This should still parse as an identifier (it's a keyword, being shadowed + // by something in a parent scope) + input = 10; + int input = input; + input += 101; + return input; +} + +int k(int a, int b) +{ + int umax = max(a, b); + + int max = umax; + return max; +} diff --git a/tests/diagnostics/bad-operator-call.slang.expected b/tests/diagnostics/bad-operator-call.slang.expected index 82eaef848..3abca8f23 100644 --- a/tests/diagnostics/bad-operator-call.slang.expected +++ b/tests/diagnostics/bad-operator-call.slang.expected @@ -22,6 +22,8 @@ core.meta.slang(2425): note 39999: candidate: func +(half, half) -> half core.meta.slang(2417): note 39999: candidate: func +(intptr_t, intptr_t) -> intptr_t core.meta.slang(2409): note 39999: candidate: func +(int64_t, int64_t) -> int64_t tests/diagnostics/bad-operator-call.slang(20): note 39999: 3 more overload candidates + a = a + b; + ^ tests/diagnostics/bad-operator-call.slang(22): error 39999: no overload for '~' applicable to arguments of type (S) a = ~b; ^ @@ -61,6 +63,8 @@ core.meta.slang(2469): note 39999: candidate: func +<3>(uint, uint3) -> uint3 core.meta.slang(2465): note 39999: candidate: func +(uint, uint) -> uint core.meta.slang(2463): note 39999: candidate: func +<4>(uint16_t4, uint16_t) -> uint16_t4 tests/diagnostics/bad-operator-call.slang(33): note 39999: 29 more overload candidates + d = c + d; + ^ } standard output = { } diff --git a/tests/diagnostics/enum-implicit-conversion.slang.expected b/tests/diagnostics/enum-implicit-conversion.slang.expected index 61164bbaa..376dab7e6 100644 --- a/tests/diagnostics/enum-implicit-conversion.slang.expected +++ b/tests/diagnostics/enum-implicit-conversion.slang.expected @@ -16,7 +16,11 @@ tests/diagnostics/enum-implicit-conversion.slang(42): error 39999: ambiguous cal int z = foo(c); ^ tests/diagnostics/enum-implicit-conversion.slang(18): note 39999: candidate: func foo(uint) -> int +int foo(uint x) { return x * 256 * 16; } + ^~~ tests/diagnostics/enum-implicit-conversion.slang(17): note 39999: candidate: func foo(int) -> int +int foo(int x) { return x * 16; } + ^~~ } standard output = { } diff --git a/tests/diagnostics/extension-visibility.slang.expected b/tests/diagnostics/extension-visibility.slang.expected index fb3aaa999..732ff4189 100644 --- a/tests/diagnostics/extension-visibility.slang.expected +++ b/tests/diagnostics/extension-visibility.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/extension-visibility.slang(17): error 39999: could not special return helper(thing); ^ tests/diagnostics/extension-visibility-a.slang(14): note 39999: see declaration of func helper<T>(T) -> int +int helper<T : IThing>(T thing) + ^~~~~~ } standard output = { } diff --git a/tests/diagnostics/generic-type-inference-fail.slang.expected b/tests/diagnostics/generic-type-inference-fail.slang.expected index 3f9753d68..17cb28ca2 100644 --- a/tests/diagnostics/generic-type-inference-fail.slang.expected +++ b/tests/diagnostics/generic-type-inference-fail.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/generic-type-inference-fail.slang(66): error 39999: could not var obj3 = CreateT_Assoc_Inner(1); // ERROR. ^ tests/diagnostics/generic-type-inference-fail.slang(18): note 39999: see declaration of func CreateT_Assoc_Inner<T>(int) -> T.TAssoc +T.TAssoc CreateT_Assoc_Inner<T:IInterface>(int inVal) + ^~~~~~~~~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/gh-38-vs.hlsl.expected b/tests/diagnostics/gh-38-vs.hlsl.expected index bc33e43aa..30d9516d5 100644 --- a/tests/diagnostics/gh-38-vs.hlsl.expected +++ b/tests/diagnostics/gh-38-vs.hlsl.expected @@ -4,6 +4,8 @@ tests/diagnostics/gh-38-fs.hlsl(5): warning 39001: explicit binding for paramete Texture2D overlappingB : register(t0); ^~~~~~~~~~~~ tests/diagnostics/gh-38-vs.hlsl(5): note: see declaration of 'overlappingA' +Texture2D overlappingA : register(t0); + ^~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/interface-requirement-not-satisfied.slang.expected b/tests/diagnostics/interface-requirement-not-satisfied.slang.expected index 464ffde25..d9a832794 100644 --- a/tests/diagnostics/interface-requirement-not-satisfied.slang.expected +++ b/tests/diagnostics/interface-requirement-not-satisfied.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/interface-requirement-not-satisfied.slang(10): error 38100: ty struct T : IFoo ^~~~ tests/diagnostics/interface-requirement-not-satisfied.slang(7): note: see declaration of 'bar' + void bar(); + ^~~ } standard output = { } diff --git a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected index cc4f310ad..3ac7dfa5f 100644 --- a/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected +++ b/tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(10): error struct Counter : IThing ^~~~~~ tests/diagnostics/interfaces/mutating-impl-of-non-mutating-req.slang(7): note: see declaration of 'processValue' + int processValue(int inValue); + ^~~~~~~~~~~~ } standard output = { } diff --git a/tests/diagnostics/local-used-before-declared.slang.expected b/tests/diagnostics/local-used-before-declared.slang.expected index 2317c4a67..52a15b7de 100644 --- a/tests/diagnostics/local-used-before-declared.slang.expected +++ b/tests/diagnostics/local-used-before-declared.slang.expected @@ -1,8 +1,8 @@ result code = -1 standard error = { -tests/diagnostics/local-used-before-declared.slang(14): fatal error 39999: local variable 'd' is being used before its declaration. - int d = 0; - ^ +tests/diagnostics/local-used-before-declared.slang(13): error 30015: undefined identifier 'd'. + float c = d + 1.0; + ^ } standard output = { } diff --git a/tests/diagnostics/local-used-in-own-declaration.slang.expected b/tests/diagnostics/local-used-in-own-declaration.slang.expected index 72582e0a9..1517663c0 100644 --- a/tests/diagnostics/local-used-in-own-declaration.slang.expected +++ b/tests/diagnostics/local-used-in-own-declaration.slang.expected @@ -1,8 +1,8 @@ result code = -1 standard error = { -tests/diagnostics/local-used-in-own-declaration.slang(12): fatal error 39999: local variable 'e' is being used before its declaration. +tests/diagnostics/local-used-in-own-declaration.slang(12): error 30015: undefined identifier 'e'. int e = e; - ^ + ^ } standard output = { } diff --git a/tests/diagnostics/overlapping-bindings.slang.expected b/tests/diagnostics/overlapping-bindings.slang.expected index bce542b2b..593f99fb4 100644 --- a/tests/diagnostics/overlapping-bindings.slang.expected +++ b/tests/diagnostics/overlapping-bindings.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/overlapping-bindings.slang(9): warning 39001: explicit binding Texture2D b : register(t0); ^ tests/diagnostics/overlapping-bindings.slang(7): note: see declaration of 'a' +Texture2D a : register(t0); + ^ } standard output = { } diff --git a/tests/diagnostics/parameter-already-defined.slang.expected b/tests/diagnostics/parameter-already-defined.slang.expected index fa9ffb581..42156a020 100644 --- a/tests/diagnostics/parameter-already-defined.slang.expected +++ b/tests/diagnostics/parameter-already-defined.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/parameter-already-defined.slang(4): error 30200: declaration o int foo( int a, float a ) { return 0; } ^ tests/diagnostics/parameter-already-defined.slang(4): note: see previous declaration of 'a' +int foo( int a, float a ) { return 0; } + ^ } standard output = { } diff --git a/tests/diagnostics/single-target-intrinsic.slang.expected b/tests/diagnostics/single-target-intrinsic.slang.expected index d7662c50e..824cd0805 100644 --- a/tests/diagnostics/single-target-intrinsic.slang.expected +++ b/tests/diagnostics/single-target-intrinsic.slang.expected @@ -4,6 +4,8 @@ tests/diagnostics/single-target-intrinsic.slang(13): error 30201: function 'doTh T doThing<T>(T in); ^~~~~~~ tests/diagnostics/single-target-intrinsic.slang(10): note: see previous definition of 'doThing' +T doThing<T>(T in); + ^~~~~~~ } standard output = { } diff --git a/tests/diagnostics/variable-redeclaration.slang.expected b/tests/diagnostics/variable-redeclaration.slang.expected index d18e5fb2a..944037b1c 100644 --- a/tests/diagnostics/variable-redeclaration.slang.expected +++ b/tests/diagnostics/variable-redeclaration.slang.expected @@ -4,23 +4,35 @@ tests/diagnostics/variable-redeclaration.slang(14): error 30200: declaration of static Texture2D gA; ^~ tests/diagnostics/variable-redeclaration.slang(12): note: see previous declaration of 'gA' +static int gA; + ^~ tests/diagnostics/variable-redeclaration.slang(44): error 30200: declaration of 'f' conflicts with existing declaration float f; ^ tests/diagnostics/variable-redeclaration.slang(43): note: see previous declaration of 'f' + int f; + ^ tests/diagnostics/variable-redeclaration.slang(51): error 30200: declaration of 'size' conflicts with existing declaration float size) ^~~~ tests/diagnostics/variable-redeclaration.slang(50): note: see previous declaration of 'size' + int size, + ^~~~ tests/diagnostics/variable-redeclaration.slang(21): error 30200: declaration of 'y' conflicts with existing declaration int y = x; ^ tests/diagnostics/variable-redeclaration.slang(20): note: see previous declaration of 'y' + int y = x; + ^ tests/diagnostics/variable-redeclaration.slang(53): error 39999: ambiguous reference to 'size' return size; ^~~~ tests/diagnostics/variable-redeclaration.slang(51): note 39999: candidate: float size + float size) + ^~~~ tests/diagnostics/variable-redeclaration.slang(50): note 39999: candidate: int size + int size, + ^~~~ } standard output = { } diff --git a/tests/preprocessor/define-redefine.slang.expected b/tests/preprocessor/define-redefine.slang.expected index 9b376bfe8..682e024ea 100644 --- a/tests/preprocessor/define-redefine.slang.expected +++ b/tests/preprocessor/define-redefine.slang.expected @@ -4,6 +4,8 @@ tests/preprocessor/define-redefine.slang(10): warning 15400: redefinition of mac #define FOO 2.0f ^~~ tests/preprocessor/define-redefine.slang(6): note: see previous definition of 'FOO' +#define FOO 1.0f + ^~~ } standard output = { } diff --git a/tests/preprocessor/include-multiple.slang.expected b/tests/preprocessor/include-multiple.slang.expected index f254ecf2f..f9facb349 100644 --- a/tests/preprocessor/include-multiple.slang.expected +++ b/tests/preprocessor/include-multiple.slang.expected @@ -4,10 +4,14 @@ tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has int bar() { return foo(); } ^~~ tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar' +int bar() { return foo(); } + ^~~ tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has a body int bar() { return foo(); } ^~~ tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar' +int bar() { return foo(); } + ^~~ } standard output = { } diff --git a/tests/preprocessor/output-includes.slang.expected b/tests/preprocessor/output-includes.slang.expected index 84f0a4411..f2fbb64f2 100644 --- a/tests/preprocessor/output-includes.slang.expected +++ b/tests/preprocessor/output-includes.slang.expected @@ -10,10 +10,14 @@ tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has int bar() { return foo(); } ^~~ tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar' +int bar() { return foo(); } + ^~~ tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has a body int bar() { return foo(); } ^~~ tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar' +int bar() { return foo(); } + ^~~ } standard output = { } |
