From 197082ca34639ffb98d49ac48ae388df959d779e Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Tue, 28 Feb 2017 09:01:43 -0500 Subject: [PATCH] Fix build warnings on some platforms Use an explicit cast from size_t to int to avoid errors like the following: glslang\glslang\MachineIndependent\preprocessor\Pp.cpp(1053) : error C2220: warning treated as error - no 'object' file generated glslang\glslang\MachineIndependent\preprocessor\Pp.cpp(1053) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data affects Pp.cpp, hlslParseHelper.cpp. Initialize local variable to get rid of warningsa about potentially uninitialized variables: glslang\hlsl\hlslparsehelper.cpp(3667) : error C2220: warning treated as error - no 'object' file generated glslang\hlsl\hlslparsehelper.cpp(3667) : warning C4701: potentially uninitialized local variable 'builtIn' used affects hlslParseHelper.cpp --- glslang/MachineIndependent/preprocessor/Pp.cpp | 2 +- hlsl/hlslParseHelper.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 4da1649e..590290bb 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -1052,7 +1052,7 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken) // TODO: preprocessor: properly handle whitespace (or lack of it) between tokens when expanding if (token == PpAtomIdentifier) { int i; - for (i = mac->args.size() - 1; i >= 0; i--) + for (i = (int)mac->args.size() - 1; i >= 0; i--) if (strcmp(pp->atomStrings.getString(mac->args[i]), ppToken->name) == 0) break; if (i >= 0) { diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 6c102e41..5ae9e742 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -2452,7 +2452,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte case EOpMethodGetDimensions: { - const int numArgs = argAggregate->getSequence().size(); + const int numArgs = (int)argAggregate->getSequence().size(); TIntermTyped* argNumItems = argAggregate->getSequence()[1]->getAsTyped(); // out num items TIntermTyped* argStride = numArgs > 2 ? argAggregate->getSequence()[2]->getAsTyped() : nullptr; // out stride @@ -3754,7 +3754,7 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct // Find it in the symbol table. // const TFunction* fnCandidate = nullptr; - bool builtIn; + bool builtIn = false; // TODO: this needs improvement: there's no way at present to look up a signature in // the symbol table for an arbitrary type. This is a temporary hack until that ability exists.