diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:11:01 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:18:09 -0700 |
| commit | 03de737f0d18526b99b59a1810c7e290b66f4be2 (patch) | |
| tree | d0e75b2524d9b7e666de0ca9fa13f3a086bf02dc /source/slang | |
| parent | 21a14cb4e0d578bc4f8a460016269a1199cac0da (diff) | |
Fix many warnings-as-errors issues.
The code should now compile cleanly with warnings as errors for VS2015 with `W3`.
Most of the changes had to do with propagating a real pointer-sized integer type through code that had been using `int`.
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/check.cpp | 50 | ||||
| -rw-r--r-- | source/slang/diagnostics.cpp | 6 | ||||
| -rw-r--r-- | source/slang/diagnostics.h | 1 | ||||
| -rw-r--r-- | source/slang/emit.cpp | 37 | ||||
| -rw-r--r-- | source/slang/lower.cpp | 26 | ||||
| -rw-r--r-- | source/slang/options.cpp | 2 | ||||
| -rw-r--r-- | source/slang/parameter-binding.cpp | 66 | ||||
| -rw-r--r-- | source/slang/preprocessor.cpp | 6 | ||||
| -rw-r--r-- | source/slang/reflection.cpp | 6 | ||||
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 5 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 39 | ||||
| -rw-r--r-- | source/slang/syntax.cpp | 4 | ||||
| -rw-r--r-- | source/slang/syntax.h | 4 | ||||
| -rw-r--r-- | source/slang/type-layout.cpp | 20 |
14 files changed, 127 insertions, 145 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index a79af3f37..2d61c60a4 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -717,7 +717,7 @@ namespace Slang // up with initializer arguments. - int argIndex = 0; + UInt argIndex = 0; for(auto fieldDeclRef : getMembersOfType<StructField>(toStructDeclRef)) { if(argIndex >= argCount) @@ -1144,27 +1144,27 @@ namespace Slang return constIntVal; } - void visit(ModifierDecl* decl) + void visit(ModifierDecl*) { // These are only used in the stdlib, so no checking is needed } - void visit(GenericTypeParamDecl* decl) + void visit(GenericTypeParamDecl*) { // These are only used in the stdlib, so no checking is needed for now } - void visit(GenericValueParamDecl* decl) + void visit(GenericValueParamDecl*) { // These are only used in the stdlib, so no checking is needed for now } - void visit(GenericTypeConstraintDecl* decl) + void visit(GenericTypeConstraintDecl*) { // These are only used in the stdlib, so no checking is needed for now } - void visit(Modifier* modifier) + void visit(Modifier*) { // Do nothing with modifiers for now } @@ -1442,7 +1442,7 @@ namespace Slang if (fstParamCount != sndParamCount) return false; - for (int ii = 0; ii < fstParamCount; ++ii) + for (UInt ii = 0; ii < fstParamCount; ++ii) { auto fstParam = fstParams[ii]; auto sndParam = sndParams[ii]; @@ -1597,10 +1597,10 @@ namespace Slang template<typename T> T* FindOuterStmt() { - int outerStmtCount = outerStmts.Count(); - for (int ii = outerStmtCount - 1; ii >= 0; --ii) + UInt outerStmtCount = outerStmts.Count(); + for (UInt ii = outerStmtCount; ii > 0; --ii) { - auto outerStmt = outerStmts[ii]; + auto outerStmt = outerStmts[ii-1]; auto found = dynamic_cast<T*>(outerStmt); if (found) return found; @@ -2988,8 +2988,8 @@ namespace Slang struct ParamCounts { - int required; - int allowed; + UInt required; + UInt allowed; }; // count the number of parameters required/allowed for a callable @@ -3048,7 +3048,7 @@ namespace Slang OverloadResolveContext& context, OverloadCandidate const& candidate) { - int argCount = context.appExpr->Arguments.Count(); + UInt argCount = context.appExpr->Arguments.Count(); ParamCounts paramCounts = { 0, 0 }; switch (candidate.flavor) { @@ -3187,7 +3187,7 @@ namespace Slang OverloadCandidate& candidate) { auto& args = context.appExpr->Arguments; - int argCount = args.Count(); + UInt argCount = args.Count(); List<DeclRef<ParameterSyntaxNode>> params; switch (candidate.flavor) @@ -3208,7 +3208,7 @@ namespace Slang // case where one or more parameters had defaults. assert(argCount <= params.Count()); - for (int ii = 0; ii < argCount; ++ii) + for (UInt ii = 0; ii < argCount; ++ii) { auto& arg = args[ii]; auto param = params[ii]; @@ -3410,7 +3410,7 @@ namespace Slang bool anyFiltered = false; // Note that we are querying the list length on every iteration, // because we might remove things. - for (int cc = 0; cc < context.bestCandidates.Count(); ++cc) + for (UInt cc = 0; cc < context.bestCandidates.Count(); ++cc) { int cmp = CompareOverloadCandidates(&candidate, &context.bestCandidates[cc]); if (cmp < 0) @@ -3624,8 +3624,8 @@ namespace Slang // Their arguments must unify assert(fst->args.Count() == snd->args.Count()); - int argCount = fst->args.Count(); - for (int aa = 0; aa < argCount; ++aa) + UInt argCount = fst->args.Count(); + for (UInt aa = 0; aa < argCount; ++aa) { if (!TryUnifyVals(constraints, fst->args[aa], snd->args[aa])) return false; @@ -3865,8 +3865,8 @@ namespace Slang auto& args = context.appExpr->Arguments; auto params = GetParameters(funcDeclRef).ToArray(); - int argCount = args.Count(); - int paramCount = params.Count(); + UInt argCount = args.Count(); + UInt paramCount = params.Count(); // Bail out on mismatch. // TODO(tfoley): need more nuance here @@ -3875,7 +3875,7 @@ namespace Slang return DeclRef<Decl>(nullptr, nullptr); } - for (int aa = 0; aa < argCount; ++aa) + for (UInt aa = 0; aa < argCount; ++aa) { #if 0 if (!TryUnifyArgAndParamTypes(constraints, args[aa], params[aa])) @@ -4289,9 +4289,9 @@ namespace Slang } } - int candidateCount = context.bestCandidates.Count(); - int maxCandidatesToPrint = 10; // don't show too many candidates at once... - int candidateIndex = 0; + UInt candidateCount = context.bestCandidates.Count(); + UInt maxCandidatesToPrint = 10; // don't show too many candidates at once... + UInt candidateIndex = 0; for (auto candidate : context.bestCandidates) { String declString = getDeclSignatureString(candidate.item); @@ -4561,7 +4561,7 @@ namespace Slang } if (params) { - for (int i = 0; i < (*params).Count(); i++) + for (UInt i = 0; i < (*params).Count(); i++) { if ((*params)[i]->HasModifier<OutModifier>()) { diff --git a/source/slang/diagnostics.cpp b/source/slang/diagnostics.cpp index 45c0c9b76..0c55a94bd 100644 --- a/source/slang/diagnostics.cpp +++ b/source/slang/diagnostics.cpp @@ -26,6 +26,12 @@ void printDiagnosticArg(StringBuilder& sb, int str) sb << str; } +void printDiagnosticArg(StringBuilder& sb, UInt val) +{ + // TODO: make this robust + sb << (int) val; +} + void printDiagnosticArg(StringBuilder& sb, Slang::String const& str) { sb << str; diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h index 4c698f95b..8834f1a6e 100644 --- a/source/slang/diagnostics.h +++ b/source/slang/diagnostics.h @@ -77,6 +77,7 @@ namespace Slang void printDiagnosticArg(StringBuilder& sb, char const* str); void printDiagnosticArg(StringBuilder& sb, int val); + void printDiagnosticArg(StringBuilder& sb, UInt val); void printDiagnosticArg(StringBuilder& sb, Slang::String const& str); void printDiagnosticArg(StringBuilder& sb, Decl* decl); void printDiagnosticArg(StringBuilder& sb, Type* type); diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 71b39aabb..0b79cb52f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -549,8 +549,8 @@ static void emitSimpleCallExpr( } Emit(context, "("); - int argCount = callExpr->Arguments.Count(); - for (int aa = 0; aa < argCount; ++aa) + UInt argCount = callExpr->Arguments.Count(); + for (UInt aa = 0; aa < argCount; ++aa) { if (aa != 0) Emit(context, ", "); EmitExpr(context, callExpr->Arguments[aa]); @@ -721,8 +721,8 @@ static void emitCallExpr( emit(context, name); Emit(context, "("); - int argCount = callExpr->Arguments.Count(); - for (int aa = 0; aa < argCount; ++aa) + UInt argCount = callExpr->Arguments.Count(); + for (UInt aa = 0; aa < argCount; ++aa) { if (aa != 0) Emit(context, ", "); EmitExpr(context, callExpr->Arguments[aa]); @@ -734,7 +734,7 @@ static void emitCallExpr( { // General case: we are going to emit some more complex text. - int argCount = callExpr->Arguments.Count(); + UInt argCount = callExpr->Arguments.Count(); Emit(context, "("); @@ -782,8 +782,8 @@ static void emitCallExpr( Emit(context, "("); EmitExpr(context, memberExpr->BaseExpression); Emit(context, ")["); - int argCount = callExpr->Arguments.Count(); - for (int aa = 0; aa < argCount; ++aa) + UInt argCount = callExpr->Arguments.Count(); + for (UInt aa = 0; aa < argCount; ++aa) { if (aa != 0) Emit(context, ", "); EmitExpr(context, callExpr->Arguments[aa]); @@ -1483,12 +1483,6 @@ static void EmitType(EmitContext* context, RefPtr<ExpressionType> type, Token co EmitType(context, type, CodePosition(), nameToken.Content, nameToken.Position); } - -static void EmitType(EmitContext* context, RefPtr<ExpressionType> type, String const& name) -{ - EmitType(context, type, CodePosition(), name, CodePosition()); -} - static void EmitType(EmitContext* context, RefPtr<ExpressionType> type) { EmitType(context, type, nullptr); @@ -1505,13 +1499,6 @@ static void EmitType(EmitContext* context, TypeExp const& typeExp, String const& EmitType(context, typeExp.type, typeExp.exp->Position, name, CodePosition()); } -static void EmitType(EmitContext* context, TypeExp const& typeExp) -{ - advanceToSourceLocation(context, typeExp.exp->Position); - EmitType(context, typeExp.type, nullptr); -} - - // Statements // Emit a statement as a `{}`-enclosed block statement, but avoid adding redundant @@ -1974,8 +1961,8 @@ static void EmitDeclRef(EmitContext* context, DeclRef<Decl> declRef) Substitutions* subst = declRef.substitutions.Ptr(); Emit(context, "<"); - int argCount = subst->args.Count(); - for (int aa = 0; aa < argCount; ++aa) + UInt argCount = subst->args.Count(); + for (UInt aa = 0; aa < argCount; ++aa) { if (aa != 0) Emit(context, ","); EmitVal(context, subst->args[aa]); @@ -2064,7 +2051,7 @@ static void EmitModifiers(EmitContext* context, RefPtr<Decl> decl) if (argCount != 0) { Emit(context, "("); - for (int aa = 0; aa < argCount; ++aa) + for (UInt aa = 0; aa < argCount; ++aa) { if (aa != 0) Emit(context, ", "); EmitExpr(context, args[aa]); @@ -3025,9 +3012,9 @@ String emitEntryPoint( // where there were global-scope uniforms. auto globalScopeLayout = programLayout->globalScopeLayout; StructTypeLayout* globalStructLayout = nullptr; - if( auto globalStructLayout = globalScopeLayout.As<StructTypeLayout>() ) + if( auto gs = globalScopeLayout.As<StructTypeLayout>() ) { - globalStructLayout = globalStructLayout.Ptr(); + globalStructLayout = gs.Ptr(); } else if(auto globalConstantBufferLayout = globalScopeLayout.As<ParameterBlockTypeLayout>()) { diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 674614cd3..e03fd878b 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -80,7 +80,7 @@ struct StructuralTransformStmtVisitor : StructuralTransformVisitorBase<V> , StmtVisitor<StructuralTransformStmtVisitor<V>, RefPtr<StatementSyntaxNode>> { - void transformFields(StatementSyntaxNode* result, StatementSyntaxNode* obj) + void transformFields(StatementSyntaxNode*, StatementSyntaxNode*) { } @@ -457,7 +457,7 @@ struct LoweringVisitor // StatementSyntaxNode* translateStmtRef( - StatementSyntaxNode* stmt) + StatementSyntaxNode*) { throw "unimplemented"; } @@ -666,13 +666,13 @@ struct LoweringVisitor } RefPtr<Substitutions> translateSubstitutions( - Substitutions* substitutions) + Substitutions* inSubstitutions) { - if (!substitutions) return nullptr; + if (!inSubstitutions) return nullptr; RefPtr<Substitutions> result = new Substitutions(); - result->genericDecl = translateDeclRef(substitutions->genericDecl).As<GenericDecl>(); - for (auto arg : substitutions->args) + result->genericDecl = translateDeclRef(inSubstitutions->genericDecl).As<GenericDecl>(); + for (auto arg : inSubstitutions->args) { result->args.Add(translateVal(arg)); } @@ -740,9 +740,8 @@ struct LoweringVisitor } else { - DeclVisitor::dispatch(declBase); + return DeclVisitor::dispatch(declBase); } - } RefPtr<Decl> lowerDecl( @@ -922,8 +921,8 @@ struct LoweringVisitor // // If this is a global variable (program scope), then add it // to the global scope. - RefPtr<ContainerDecl> parentDecl = decl->ParentDecl; - if (auto parentModuleDecl = parentDecl.As<ProgramSyntaxNode>()) + RefPtr<ContainerDecl> pp = decl->ParentDecl; + if (auto parentModuleDecl = pp.As<ProgramSyntaxNode>()) { addMember( translateDeclRef(parentModuleDecl), @@ -1138,10 +1137,6 @@ struct LoweringVisitor subscriptExpr->Position = varExpr->Position; subscriptExpr->BaseExpression = varExpr; - // TODO: we need to construct syntax for a loop to initialize - // the array here... - throw "unimplemented"; - // Note that we use the original `varLayout` that was passed in, // since that is the layout that will ultimately need to be // used on the array elements. @@ -1154,6 +1149,9 @@ struct LoweringVisitor varLayout, subscriptExpr); + // TODO: we need to construct syntax for a loop to initialize + // the array here... + throw "unimplemented"; } else if (auto declRefType = varType->As<DeclRefType>()) { diff --git a/source/slang/options.cpp b/source/slang/options.cpp index cced0f0ff..db949e78d 100644 --- a/source/slang/options.cpp +++ b/source/slang/options.cpp @@ -80,7 +80,7 @@ struct OptionsParser { auto translationUnitIndex = spAddTranslationUnit(compileRequest, language, nullptr); - assert(translationUnitIndex == rawTranslationUnits.Count()); + assert(UInt(translationUnitIndex) == rawTranslationUnits.Count()); RawTranslationUnit rawTranslationUnit; rawTranslationUnit.sourceLanguage = language; diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index 8d008618f..5811fd9fa 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -14,8 +14,8 @@ namespace Slang { // Information on ranges of registers already claimed/used struct UsedRange { - int begin; - int end; + UInt begin; + UInt end; }; bool operator<(UsedRange left, UsedRange right) { @@ -51,7 +51,7 @@ struct UsedRanges ranges.Sort(); } - void Add(int begin, int end) + void Add(UInt begin, UInt end) { UsedRange range; range.begin = begin; @@ -61,16 +61,16 @@ struct UsedRanges // Try to find space for `count` entries - int Allocate(int count) + UInt Allocate(UInt count) { - int begin = 0; + UInt begin = 0; - int rangeCount = ranges.Count(); - for (int rr = 0; rr < rangeCount; ++rr) + UInt rangeCount = ranges.Count(); + for (UInt rr = 0; rr < rangeCount; ++rr) { // try to fit in before this range... - int end = ranges[rr].begin; + UInt end = ranges[rr].begin; // If there is enough space... if (end >= begin + count) @@ -165,8 +165,8 @@ struct ParameterBindingContext struct LayoutSemanticInfo { LayoutResourceKind kind; // the register kind - int space; - int index; + UInt space; + UInt index; // TODO: need to deal with component-granularity binding... }; @@ -229,15 +229,15 @@ LayoutSemanticInfo ExtractLayoutSemanticInfo( // TODO: handle component mask part of things... info.kind = kind; - info.index = index; + info.index = (int) index; info.space = space; return info; } static bool doesParameterMatch( - ParameterBindingContext* context, - RefPtr<VarLayout> varLayout, - ParameterInfo* parameterInfo) + ParameterBindingContext*, + RefPtr<VarLayout>, + ParameterInfo*) { // TODO: need to implement this eventually return true; @@ -250,20 +250,23 @@ static bool doesParameterMatch( template<typename T> static bool findLayoutArg( RefPtr<ModifiableSyntaxNode> syntax, - int* outVal) + UInt* outVal) { for( auto modifier : syntax->GetModifiersOfType<T>() ) { - *outVal = (int) strtol(modifier->valToken.Content.Buffer(), nullptr, 10); - return true; + if( modifier ) + { + *outVal = (UInt) strtoull(modifier->valToken.Content.Buffer(), nullptr, 10); + return true; + } } return false; } template<typename T> static bool findLayoutArg( - DeclRef<Decl> declRef, - int* outVal) + DeclRef<Decl> declRef, + UInt* outVal) { return findLayoutArg<T>(declRef.getDecl(), outVal); } @@ -395,7 +398,6 @@ getTypeLayoutForGlobalShaderParameter( ParameterBindingContext* context, VarDeclBase* varDecl) { - auto rules = context->layoutRules; switch( context->shared->sourceLanguage ) { case SourceLanguage::Slang: @@ -478,7 +480,7 @@ static void addExplicitParameterBinding( ParameterBindingContext* context, RefPtr<ParameterInfo> parameterInfo, LayoutSemanticInfo const& semanticInfo, - int count) + UInt count) { auto kind = semanticInfo.kind; @@ -575,7 +577,7 @@ static void addExplicitParameterBindings_GLSL( LayoutSemanticInfo semanticInfo; semanticInfo.index = 0; semanticInfo.space = 0; - if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::DescriptorTableSlot)) ) + if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::DescriptorTableSlot)) != nullptr ) { // Try to find `binding` and `set` if(!findLayoutArg<GLSLBindingLayoutModifier>(varDecl, &semanticInfo.index)) @@ -583,19 +585,19 @@ static void addExplicitParameterBindings_GLSL( findLayoutArg<GLSLSetLayoutModifier>(varDecl, &semanticInfo.space); } - else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::VertexInput)) ) + else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::VertexInput)) != nullptr ) { // Try to find `location` binding if(!findLayoutArg<GLSLLocationLayoutModifier>(varDecl, &semanticInfo.index)) return; } - else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::FragmentOutput)) ) + else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::FragmentOutput)) != nullptr ) { // Try to find `location` binding if(!findLayoutArg<GLSLLocationLayoutModifier>(varDecl, &semanticInfo.index)) return; } - else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::SpecializationConstant)) ) + else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::SpecializationConstant)) != nullptr ) { // Try to find `constant_id` binding if(!findLayoutArg<GLSLConstantIDLayoutModifier>(varDecl, &semanticInfo.index)) @@ -733,8 +735,8 @@ SimpleSemanticInfo decomposeSimpleSemantic( // look for a trailing sequence of decimal digits // at the end of the composed name - int length = composedName.Length(); - int indexLoc = length; + UInt length = composedName.Length(); + UInt indexLoc = length; while( indexLoc > 0 ) { auto c = composedName[indexLoc-1]; @@ -888,29 +890,29 @@ static RefPtr<TypeLayout> processEntryPointParameter( { return processSimpleEntryPointParameter(context, basicType, state); } - else if(auto basicType = type->As<VectorExpressionType>()) + else if(auto vectorType = type->As<VectorExpressionType>()) { - return processSimpleEntryPointParameter(context, basicType, state); + return processSimpleEntryPointParameter(context, vectorType, state); } // A matrix is processed as if it was an array of rows else if( auto matrixType = type->As<MatrixExpressionType>() ) { auto rowCount = GetIntVal(matrixType->getRowCount()); - return processSimpleEntryPointParameter(context, basicType, state, (int) rowCount); + return processSimpleEntryPointParameter(context, matrixType, state, (int) rowCount); } else if( auto arrayType = type->As<ArrayExpressionType>() ) { // Note: Bad Things will happen if we have an array input // without a semantic already being enforced. - auto elementCount = GetIntVal(arrayType->ArrayLength); + auto elementCount = (UInt) GetIntVal(arrayType->ArrayLength); // We use the first element to derive the layout for the element type auto elementTypeLayout = processEntryPointParameter(context, arrayType->BaseType, state); // We still walk over subsequent elements to make sure they consume resources // as needed - for( int ii = 1; ii < elementCount; ++ii ) + for( UInt ii = 1; ii < elementCount; ++ii ) { processEntryPointParameter(context, arrayType->BaseType, state); } diff --git a/source/slang/preprocessor.cpp b/source/slang/preprocessor.cpp index f84355018..a186ce201 100644 --- a/source/slang/preprocessor.cpp +++ b/source/slang/preprocessor.cpp @@ -600,8 +600,8 @@ static void MaybeBeginMacroExpansion( expansion->environment = &expansion->argumentEnvironment; // Try to read any arguments present. - int paramCount = macro->params.Count(); - int argIndex = 0; + UInt paramCount = macro->params.Count(); + UInt argIndex = 0; switch (PeekRawTokenType(preprocessor)) { @@ -702,7 +702,7 @@ static void MaybeBeginMacroExpansion( GetSink(preprocessor)->diagnose(PeekLoc(preprocessor), Diagnostics::expectedTokenInMacroArguments, TokenType::RParent, PeekRawTokenType(preprocessor)); } - int argCount = argIndex; + UInt argCount = argIndex; if (argCount != paramCount) { // TODO: diagnose diff --git a/source/slang/reflection.cpp b/source/slang/reflection.cpp index 40cd7061b..f71435c6f 100644 --- a/source/slang/reflection.cpp +++ b/source/slang/reflection.cpp @@ -191,11 +191,11 @@ SLANG_API size_t spReflectionType_GetElementCount(SlangReflectionType* inType) if(auto arrayType = dynamic_cast<ArrayExpressionType*>(type)) { - return GetIntVal(arrayType->ArrayLength); + return (size_t) GetIntVal(arrayType->ArrayLength); } else if( auto vectorType = dynamic_cast<VectorExpressionType*>(type)) { - return GetIntVal(vectorType->elementCount); + return (size_t) GetIntVal(vectorType->elementCount); } return 0; @@ -688,7 +688,7 @@ SLANG_API unsigned spReflection_GetParameterCount(SlangReflection* inProgram) if(auto globalStructLayout = globalLayout.As<StructTypeLayout>()) { - return globalStructLayout->fields.Count(); + return (unsigned) globalStructLayout->fields.Count(); } return 0; diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index 513fa3b96..ff727cbb6 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -1598,10 +1598,9 @@ namespace Slang { 3, "Alpha" }, }; - for(auto cc : kGatherComponets) + for(auto kk : kGatherComponets) { - auto componentIndex = cc.componentIndex; - auto componentName = cc.componentName; + auto componentName = kk.componentName; EMIT_LINE_DIRECTIVE(); sb << "vector<T, 4> Gather" << componentName << "(SamplerState s, "; diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 182a5818d..c4944c5a4 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -19,17 +19,6 @@ namespace Slang { -static void stdlibDiagnosticCallback( - char const* message, - void* userData) -{ - fputs(message, stderr); - fflush(stderr); -#ifdef WIN32 - OutputDebugStringA(message); -#endif -} - class Session { public: @@ -281,9 +270,9 @@ int CompileRequest::executeActions() return err; } -int CompileRequest::addTranslationUnit(SourceLanguage language, String const& name) +int CompileRequest::addTranslationUnit(SourceLanguage language, String const&) { - int result = translationUnits.Count(); + UInt result = translationUnits.Count(); RefPtr<TranslationUnitRequest> translationUnit = new TranslationUnitRequest(); translationUnit->compileRequest = this; @@ -291,7 +280,7 @@ int CompileRequest::addTranslationUnit(SourceLanguage language, String const& na translationUnits.Add(translationUnit); - return result; + return (int) result; } void CompileRequest::addTranslationUnitSourceString( @@ -336,27 +325,27 @@ void CompileRequest::addTranslationUnitSourceFile( int CompileRequest::addEntryPoint( int translationUnitIndex, String const& name, - Profile profile) + Profile entryPointProfile) { RefPtr<EntryPointRequest> entryPoint = new EntryPointRequest(); entryPoint->compileRequest = this; entryPoint->name = name; - entryPoint->profile = profile; + entryPoint->profile = entryPointProfile; entryPoint->translationUnitIndex = translationUnitIndex; auto translationUnit = translationUnits[translationUnitIndex].Ptr(); translationUnit->entryPoints.Add(entryPoint); - int result = entryPoints.Count(); + UInt result = entryPoints.Count(); entryPoints.Add(entryPoint); - return result; + return (int) result; } RefPtr<ProgramSyntaxNode> CompileRequest::loadModule( String const& name, String const& path, String const& source, - CodePosition const& loc) + CodePosition const&) { RefPtr<TranslationUnitRequest> translationUnit = new TranslationUnitRequest(); translationUnit->compileRequest = this; @@ -714,7 +703,7 @@ SLANG_API void spAddTranslationUnitSourceFile( auto req = REQ(request); if(!path) return; if(translationUnitIndex < 0) return; - if(translationUnitIndex >= req->translationUnits.Count()) return; + if(Slang::UInt(translationUnitIndex) >= req->translationUnits.Count()) return; req->addTranslationUnitSourceFile( translationUnitIndex, @@ -732,7 +721,7 @@ SLANG_API void spAddTranslationUnitSourceString( auto req = REQ(request); if(!source) return; if(translationUnitIndex < 0) return; - if(translationUnitIndex >= req->translationUnits.Count()) return; + if(Slang::UInt(translationUnitIndex) >= req->translationUnits.Count()) return; if(!path) path = ""; @@ -744,7 +733,7 @@ SLANG_API void spAddTranslationUnitSourceString( } SLANG_API SlangProfileID spFindProfile( - SlangSession* session, + SlangSession*, char const* name) { return Slang::Profile::LookUp(name).raw; @@ -760,7 +749,7 @@ SLANG_API int spAddEntryPoint( auto req = REQ(request); if(!name) return -1; if(translationUnitIndex < 0) return -1; - if(translationUnitIndex >= req->translationUnits.Count()) return -1; + if(Slang::UInt(translationUnitIndex) >= req->translationUnits.Count()) return -1; return req->addEntryPoint( translationUnitIndex, @@ -785,7 +774,7 @@ spGetDependencyFileCount( { if(!request) return 0; auto req = REQ(request); - return req->mDependencyFilePaths.Count(); + return (int) req->mDependencyFilePaths.Count(); } /** Get the path to a file this compilation dependend on. @@ -805,7 +794,7 @@ spGetTranslationUnitCount( SlangCompileRequest* request) { auto req = REQ(request); - return req->translationUnits.Count(); + return (int) req->translationUnits.Count(); } // Get the output code associated with a specific translation unit diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 12d8c90bb..94e0d5914 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -782,9 +782,9 @@ void ExpressionType::accept(IValVisitor* visitor, void* extra) if (genericDecl != subst->genericDecl) return false; - int argCount = args.Count(); + UInt argCount = args.Count(); assert(args.Count() == subst->args.Count()); - for (int aa = 0; aa < argCount; ++aa) + for (UInt aa = 0; aa < argCount; ++aa) { if (!args[aa]->EqualsVal(subst->args[aa].Ptr())) return false; diff --git a/source/slang/syntax.h b/source/slang/syntax.h index 6587e18c3..4329f6cbd 100644 --- a/source/slang/syntax.h +++ b/source/slang/syntax.h @@ -420,9 +420,9 @@ namespace Slang // TODO(tfoley): It is ugly to have these. // We should probably fix the call sites instead. RefPtr<T>& First() { return *begin(); } - int Count() + UInt Count() { - int count = 0; + UInt count = 0; for (auto iter : (*this)) { (void)iter; diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index bef777ce5..2fcf64226 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -225,7 +225,7 @@ struct DefaultVaryingLayoutRulesImpl : DefaultLayoutRulesImpl return kind; } - SimpleLayoutInfo GetScalarLayout(BaseType baseType) override + SimpleLayoutInfo GetScalarLayout(BaseType) override { // Assume that all scalars take up one "slot" return SimpleLayoutInfo( @@ -233,7 +233,7 @@ struct DefaultVaryingLayoutRulesImpl : DefaultLayoutRulesImpl 1); } - virtual SimpleLayoutInfo GetScalarLayout(slang::TypeReflection::ScalarType scalarType) + virtual SimpleLayoutInfo GetScalarLayout(slang::TypeReflection::ScalarType) { // Assume that all scalars take up one "slot" return SimpleLayoutInfo( @@ -241,7 +241,7 @@ struct DefaultVaryingLayoutRulesImpl : DefaultLayoutRulesImpl 1); } - SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo elementInfo, size_t elementCount) override + SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo, size_t) override { // Vectors take up one slot by default // @@ -276,7 +276,7 @@ struct GLSLSpecializationConstantLayoutRulesImpl : DefaultLayoutRulesImpl return LayoutResourceKind::SpecializationConstant; } - SimpleLayoutInfo GetScalarLayout(BaseType baseType) override + SimpleLayoutInfo GetScalarLayout(BaseType) override { // Assume that all scalars take up one "slot" return SimpleLayoutInfo( @@ -284,7 +284,7 @@ struct GLSLSpecializationConstantLayoutRulesImpl : DefaultLayoutRulesImpl 1); } - virtual SimpleLayoutInfo GetScalarLayout(slang::TypeReflection::ScalarType scalarType) + virtual SimpleLayoutInfo GetScalarLayout(slang::TypeReflection::ScalarType) { // Assume that all scalars take up one "slot" return SimpleLayoutInfo( @@ -292,7 +292,7 @@ struct GLSLSpecializationConstantLayoutRulesImpl : DefaultLayoutRulesImpl 1); } - SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo elementInfo, size_t elementCount) override + SimpleLayoutInfo GetVectorLayout(SimpleLayoutInfo, size_t elementCount) override { // GLSL doesn't support vectors of specialization constants, // but we will assume that, if supported, they would use one slot per element. @@ -308,7 +308,7 @@ GLSLSpecializationConstantLayoutRulesImpl kGLSLSpecializationConstantLayoutRules struct GLSLObjectLayoutRulesImpl : ObjectLayoutRulesImpl { - virtual SimpleLayoutInfo GetObjectLayout(ShaderParameterKind kind) override + virtual SimpleLayoutInfo GetObjectLayout(ShaderParameterKind) override { // In Vulkan GLSL, pretty much every object is just a descriptor-table slot. // We can refine this method once we support a case where this isn't true. @@ -954,7 +954,7 @@ SimpleLayoutInfo GetLayoutImpl( return GetSimpleLayoutImpl( rules->GetVectorLayout( GetLayout(vecType->elementType.Ptr(), rules), - GetIntVal(vecType->elementCount)), + (size_t) GetIntVal(vecType->elementCount)), type, rules, outTypeLayout); @@ -964,8 +964,8 @@ SimpleLayoutInfo GetLayoutImpl( return GetSimpleLayoutImpl( rules->GetMatrixLayout( GetLayout(matType->getElementType(), rules), - GetIntVal(matType->getRowCount()), - GetIntVal(matType->getColumnCount())), + (size_t) GetIntVal(matType->getRowCount()), + (size_t) GetIntVal(matType->getColumnCount())), type, rules, outTypeLayout); |
