From: John Kessenich Date: Fri, 15 May 2015 17:30:55 +0000 (+0000) Subject: glslang: Fix over 100 warnings from MSVC warning level 4. X-Git-Tag: upstream/0.1~553 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93dfbe1309f2694212e6630c4e50495a8adf7e92;p=platform%2Fupstream%2Fglslang.git glslang: Fix over 100 warnings from MSVC warning level 4. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31202 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index ec0d95e..79b1a18 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -99,7 +99,7 @@ protected: spv::Id createUnaryOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, spv::Id operand, bool isFloat); spv::Id createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destTypeId, spv::Id operand); spv::Id makeSmearedConstant(spv::Id constant, int vectorSize); - spv::Id createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector& operands, bool isUnsigned); + spv::Id createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector& operands); spv::Id createNoArgOperation(glslang::TOperator op); spv::Id getSymbolId(const glslang::TIntermSymbol* node); void addDecoration(spv::Id id, spv::Decoration dec); @@ -1029,11 +1029,8 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt result = createUnaryOperation(node->getOp(), precision, convertGlslangToSpvType(node->getType()), operands.front(), node->getType().getBasicType() == glslang::EbtFloat || node->getType().getBasicType() == glslang::EbtDouble); break; default: - { - const glslang::TType& type = glslangOperands.front()->getAsTyped()->getType(); - result = createMiscOperation(node->getOp(), precision, convertGlslangToSpvType(node->getType()), operands, type.getBasicType() == glslang::EbtUint); - break; - } + result = createMiscOperation(node->getOp(), precision, convertGlslangToSpvType(node->getType()), operands); + break; } if (noReturnValue) @@ -1271,7 +1268,7 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler) // Do full recursive conversion of an arbitrary glslang type to a SPIR-V Id. spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type) { - spv::Id spvType; + spv::Id spvType = 0; switch (type.getBasicType()) { case glslang::EbtVoid: @@ -2142,8 +2139,8 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv: spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Decoration precision, spv::Id destType, spv::Id operand) { spv::Op convOp = spv::OpNop; - spv::Id zero; - spv::Id one; + spv::Id zero = 0; + spv::Id one = 0; int vectorSize = builder.isVectorType(destType) ? builder.getNumTypeComponents(destType) : 0; @@ -2246,7 +2243,7 @@ spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vector return builder.makeCompositeConstant(vectorTypeId, components); } -spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector& operands, bool isUnsigned) +spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector& operands) { spv::Op opCode = spv::OpNop; int libCall = -1; @@ -2502,7 +2499,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TType& glslangT } else { // we have a non-aggregate (scalar) constant bool zero = nextConst >= consts.size(); - spv::Id scalar; + spv::Id scalar = 0; switch (glslangType.getBasicType()) { case glslang::EbtInt: scalar = builder.makeIntConstant(zero ? 0 : consts[nextConst].getIConst()); diff --git a/SPIRV/SPVRemapper.h b/SPIRV/SPVRemapper.h index 73b09ec..5af95f9 100644 --- a/SPIRV/SPVRemapper.h +++ b/SPIRV/SPVRemapper.h @@ -79,9 +79,9 @@ namespace spv { class spirvbin_t : public spirvbin_base_t { public: - spirvbin_t(int verbose = 0) { } + spirvbin_t(int /*verbose = 0*/) { } - void remap(std::vector& spv, unsigned int opts = 0) + void remap(std::vector& /*spv*/, unsigned int /*opts = 0*/) { printf("Tool not compiled for C++11, which is required for SPIR-V remapping.\n"); } diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index e46c02c..abfc832 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -117,7 +117,7 @@ Id Builder::makePointer(StorageClass storageClass, Id pointee) Instruction* type; for (int t = 0; t < (int)groupedTypes[OpTypePointer].size(); ++t) { type = groupedTypes[OpTypePointer][t]; - if (type->getImmediateOperand(0) == storageClass && + if (type->getImmediateOperand(0) == (unsigned)storageClass && type->getIdOperand(1) == pointee) return type->getResultId(); } @@ -139,8 +139,8 @@ Id Builder::makeIntegerType(int width, bool hasSign) Instruction* type; for (int t = 0; t < (int)groupedTypes[OpTypeInt].size(); ++t) { type = groupedTypes[OpTypeInt][t]; - if (type->getImmediateOperand(0) == width && - type->getImmediateOperand(1) == (hasSign ? 1 : 0)) + if (type->getImmediateOperand(0) == (unsigned)width && + type->getImmediateOperand(1) == (hasSign ? 1u : 0u)) return type->getResultId(); } @@ -161,7 +161,7 @@ Id Builder::makeFloatType(int width) Instruction* type; for (int t = 0; t < (int)groupedTypes[OpTypeFloat].size(); ++t) { type = groupedTypes[OpTypeFloat][t]; - if (type->getImmediateOperand(0) == width) + if (type->getImmediateOperand(0) == (unsigned)width) return type->getResultId(); } @@ -196,7 +196,7 @@ Id Builder::makeVectorType(Id component, int size) for (int t = 0; t < (int)groupedTypes[OpTypeVector].size(); ++t) { type = groupedTypes[OpTypeVector][t]; if (type->getIdOperand(0) == component && - type->getImmediateOperand(1) == size) + type->getImmediateOperand(1) == (unsigned)size) return type->getResultId(); } @@ -222,7 +222,7 @@ Id Builder::makeMatrixType(Id component, int cols, int rows) for (int t = 0; t < (int)groupedTypes[OpTypeMatrix].size(); ++t) { type = groupedTypes[OpTypeMatrix][t]; if (type->getIdOperand(0) == column && - type->getImmediateOperand(1) == cols) + type->getImmediateOperand(1) == (unsigned)cols) return type->getResultId(); } @@ -268,7 +268,7 @@ Id Builder::makeFunctionType(Id returnType, std::vector& paramTypes) Instruction* type; for (int t = 0; t < (int)groupedTypes[OpTypeFunction].size(); ++t) { type = groupedTypes[OpTypeFunction][t]; - if (type->getIdOperand(0) != returnType || paramTypes.size() != type->getNumOperands() - 1) + if (type->getIdOperand(0) != returnType || (int)paramTypes.size() != type->getNumOperands() - 1) continue; bool mismatch = false; for (int p = 0; p < (int)paramTypes.size(); ++p) { @@ -547,13 +547,13 @@ Id Builder::makeDoubleConstant(double d) Id Builder::findCompositeConstant(Op typeClass, std::vector& comps) const { - Instruction* constant; + Instruction* constant = 0; bool found = false; for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) { constant = groupedConstants[typeClass][i]; // same shape? - if (constant->getNumOperands() != comps.size()) + if (constant->getNumOperands() != (int)comps.size()) continue; // same contents? @@ -1049,7 +1049,7 @@ void Builder::promoteScalar(Decoration precision, Id& left, Id& right) } // Comments in header -Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType) +Id Builder::smearScalar(Decoration /*precision*/, Id scalar, Id vectorType) { assert(getNumComponents(scalar) == 1); @@ -1066,7 +1066,7 @@ Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType) } // Comments in header -Id Builder::createBuiltinCall(Decoration precision, Id resultType, Id builtins, int entryPoint, std::vector& args) +Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builtins, int entryPoint, std::vector& args) { Instruction* inst = new Instruction(getUniqueId(), resultType, OpExtInst); inst->addIdOperand(builtins); @@ -1259,8 +1259,6 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter // Comments in header Id Builder::createCompare(Decoration precision, Id value1, Id value2, bool equal) { - Instruction* compare = 0; - spv::Op binOp = spv::OpNop; Id boolType = makeBoolType(); Id valueType = getTypeId(value1); @@ -1461,7 +1459,7 @@ Id Builder::createCompositeConstruct(Id typeId, std::vector& constituents) // Vector or scalar constructor Id Builder::createConstructor(Decoration precision, const std::vector& sources, Id resultTypeId) { - Id result; + Id result = 0; unsigned int numTargetComponents = getNumTypeComponents(resultTypeId); unsigned int targetComponent = 0; @@ -1701,7 +1699,7 @@ void Builder::nextSwitchSegment(std::vector& segmentBlock, int nextSegme } // Comments in header -void Builder::endSwitch(std::vector& segmentBlock) +void Builder::endSwitch(std::vector& /*segmentBlock*/) { // Close out previous segment by jumping, if necessary, to next segment if (! buildPoint->isTerminated()) @@ -1840,7 +1838,7 @@ void Builder::accessChainStore(Id rvalue) } // Comments in header -Id Builder::accessChainLoad(Decoration precision) +Id Builder::accessChainLoad(Decoration /*precision*/) { Id id; @@ -1991,7 +1989,7 @@ void Builder::simplifyAccessChainSwizzle() // Utility method for creating a new block and setting the insert point to // be in it. This is useful for flow-control operations that need a "dummy" // block proceeding them (e.g. instructions after a discard, etc). -void Builder::createAndSetNoPredecessorBlock(const char* name) +void Builder::createAndSetNoPredecessorBlock(const char* /*name*/) { Block* block = new Block(getUniqueId(), buildPoint->getParent()); block->setUnreachable(); diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index b4417df..b38d4a5 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -101,7 +101,7 @@ public: Id makeMatrixType(Id component, int cols, int rows); Id makeArrayType(Id element, unsigned size); Id makeFunctionType(Id returnType, std::vector& paramTypes); - enum samplerContent { + enum samplerContent : unsigned { samplerContentTexture, samplerContentImage, samplerContentTextureFilter @@ -250,7 +250,7 @@ public: // If the value passed in is an instruction and the precision is not EMpNone, // it gets tagged with the requested precision. - void setPrecision(Id value, Decoration precision) + void setPrecision(Id /* value */, Decoration /* precision */) { // TODO } @@ -318,6 +318,9 @@ public: void makeEndIf(); private: + If(const If&); + If& operator=(If&); + Builder& builder; Id condition; Function* function; diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 3daff74..7a9b10d 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -70,6 +70,9 @@ public: void processInstructions(); protected: + SpirvStream(SpirvStream&); + SpirvStream& operator=(SpirvStream&); + Op getOpCode(int id) const { return idInstruction[id] ? (Op)(stream[idInstruction[id]] & OpCodeMask) : OpNop; } // Output methods @@ -278,7 +281,7 @@ void SpirvStream::disassembleString() out << "\""; } -void SpirvStream::disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands) +void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, int numOperands) { // Process the opcode diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h index 718b3d5..ec75824 100644 --- a/SPIRV/spvIR.h +++ b/SPIRV/spvIR.h @@ -210,6 +210,7 @@ public: protected: Block(const Block&); + Block& operator=(Block&); // To enforce keeping parent and ownership in sync: friend Function; @@ -244,7 +245,7 @@ public: Id getParamId(int p) { return parameterInstructions[p]->getResultId(); } void addBlock(Block* block) { blocks.push_back(block); } - void popBlock(Block* block) { assert(blocks.back() == block); blocks.pop_back(); } + void popBlock(Block*) { blocks.pop_back(); } Module& getParent() const { return parent; } Block* getEntryBlock() const { return blocks.front(); } @@ -269,6 +270,8 @@ public: protected: Function(const Function&); + Function& operator=(Function&); + Module& parent; Instruction functionInstruction; std::vector parameterInstructions; diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 4f38566..af6f8dc 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -938,7 +938,7 @@ char** ReadFileData(const char* fileName) printf("Error allocating memory\n"); return 0; } - if (fread(fdata,1,count, in)!=count) { + if ((int)fread(fdata,1,count, in) != count) { printf("Error reading input file: %s\n", fileName); return 0; } diff --git a/glslang/GenericCodeGen/CodeGen.cpp b/glslang/GenericCodeGen/CodeGen.cpp index 7628c49..dc78342 100644 --- a/glslang/GenericCodeGen/CodeGen.cpp +++ b/glslang/GenericCodeGen/CodeGen.cpp @@ -68,7 +68,7 @@ void DeleteCompiler(TCompiler* compiler) // // Generate code from the given parse tree // -bool TGenericCompiler::compile(TIntermNode *root, int version, EProfile profile) +bool TGenericCompiler::compile(TIntermNode* /*root*/, int /*version*/, EProfile /*profile*/) { haveValidObjectCode = true; diff --git a/glslang/GenericCodeGen/Link.cpp b/glslang/GenericCodeGen/Link.cpp index 60762d8..8160999 100644 --- a/glslang/GenericCodeGen/Link.cpp +++ b/glslang/GenericCodeGen/Link.cpp @@ -46,7 +46,7 @@ class TGenericLinker : public TLinker { public: TGenericLinker(EShExecutable e, int dOptions) : TLinker(e, infoSink), debugOptions(dOptions) { } bool link(TCompilerList&, TUniformMap*) { return true; } - void getAttributeBindings(ShBindingTable const **t) const { } + void getAttributeBindings(ShBindingTable const **) const { } TInfoSink infoSink; int debugOptions; }; @@ -57,7 +57,7 @@ public: class TUniformLinkedMap : public TUniformMap { public: TUniformLinkedMap() { } - virtual int getLocation(const char* name) { return 0; } + virtual int getLocation(const char*) { return 0; } }; TShHandleBase* ConstructLinker(EShExecutable executable, int debugOptions) diff --git a/glslang/Include/ConstantUnion.h b/glslang/Include/ConstantUnion.h index 9317504..62b489d 100644 --- a/glslang/Include/ConstantUnion.h +++ b/glslang/Include/ConstantUnion.h @@ -185,8 +185,6 @@ public: assert(false && "Default missing"); return false; } - - return false; } bool operator<(const TConstUnion& constant) const @@ -212,8 +210,6 @@ public: assert(false && "Default missing"); return false; } - - return false; } TConstUnion operator+(const TConstUnion& constant) const diff --git a/glslang/Include/PoolAlloc.h b/glslang/Include/PoolAlloc.h index 59ddc41..de41053 100644 --- a/glslang/Include/PoolAlloc.h +++ b/glslang/Include/PoolAlloc.h @@ -214,11 +214,13 @@ protected: typedef std::vector tAllocStack; // Track allocations if and only if we're using guard blocks +#ifndef GUARD_BLOCKS + void* initializeAllocation(tHeader*, unsigned char* memory, size_t) { +#else void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) { -# ifdef GUARD_BLOCKS new(memory) TAllocation(numBytes, memory, block->lastAllocation); block->lastAllocation = reinterpret_cast(memory); -# endif +#endif // This is optimized entirely away if GUARD_BLOCKS is not defined. return TAllocation::offsetAllocation(memory); @@ -314,7 +316,7 @@ public: TPoolAllocator& getAllocator() const { return allocator; } protected: - pool_allocator& operator=(const pool_allocator& rhs) { return *this; } + pool_allocator& operator=(const pool_allocator&) { return *this; } TPoolAllocator& allocator; }; diff --git a/glslang/Include/ShHandle.h b/glslang/Include/ShHandle.h index 5e61a98..68b56cc 100644 --- a/glslang/Include/ShHandle.h +++ b/glslang/Include/ShHandle.h @@ -98,6 +98,8 @@ public: TInfoSink& infoSink; protected: + TCompiler& operator=(TCompiler&); + EShLanguage language; bool haveValidObjectCode; }; @@ -137,6 +139,7 @@ public: virtual TInfoSink& getInfoSink() { return infoSink; } TInfoSink& infoSink; protected: + TLinker& operator=(TLinker&); EShExecutable executable; bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index 0647a76..46d5085 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -694,15 +694,15 @@ public: maxDepth(0) { } virtual ~TIntermTraverser() { } - virtual void visitSymbol(TIntermSymbol*) { } - virtual void visitConstantUnion(TIntermConstantUnion*) { } - virtual bool visitBinary(TVisit visit, TIntermBinary*) { return true; } - virtual bool visitUnary(TVisit visit, TIntermUnary*) { return true; } - virtual bool visitSelection(TVisit visit, TIntermSelection*) { return true; } - virtual bool visitAggregate(TVisit visit, TIntermAggregate*) { return true; } - virtual bool visitLoop(TVisit visit, TIntermLoop*) { return true; } - virtual bool visitBranch(TVisit visit, TIntermBranch*) { return true; } - virtual bool visitSwitch(TVisit, TIntermSwitch* node) { return true; } + virtual void visitSymbol(TIntermSymbol*) { } + virtual void visitConstantUnion(TIntermConstantUnion*) { } + virtual bool visitBinary(TVisit, TIntermBinary*) { return true; } + virtual bool visitUnary(TVisit, TIntermUnary*) { return true; } + virtual bool visitSelection(TVisit, TIntermSelection*) { return true; } + virtual bool visitAggregate(TVisit, TIntermAggregate*) { return true; } + virtual bool visitLoop(TVisit, TIntermLoop*) { return true; } + virtual bool visitBranch(TVisit, TIntermBranch*) { return true; } + virtual bool visitSwitch(TVisit, TIntermSwitch*) { return true; } int getMaxDepth() const { return maxDepth; } @@ -730,6 +730,8 @@ public: const bool rightToLeft; protected: + TIntermTraverser& operator=(TIntermTraverser&); + int depth; int maxDepth; diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index 728245a..6590ee3 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -646,10 +646,10 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode) // some arguments are scalars instead of matching vectors; simulate a smear int arg0comp = std::min(comp, children[0]->getAsTyped()->getType().getVectorSize() - 1); - int arg1comp; + int arg1comp = 0; if (children.size() > 1) arg1comp = std::min(comp, children[1]->getAsTyped()->getType().getVectorSize() - 1); - int arg2comp; + int arg2comp = 0; if (children.size() > 2) arg2comp = std::min(comp, children[2]->getAsTyped()->getType().getVectorSize() - 1); diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 2735a9f..10ed73c 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -1951,7 +1951,7 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi // // Add all the texture lookup functions for the given type. // -void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int version, EProfile profile) +void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int /*version*/, EProfile /*profile*/) { // // texturing diff --git a/glslang/MachineIndependent/IntermTraverse.cpp b/glslang/MachineIndependent/IntermTraverse.cpp index 3bca44d..b0ac4c7 100644 --- a/glslang/MachineIndependent/IntermTraverse.cpp +++ b/glslang/MachineIndependent/IntermTraverse.cpp @@ -56,7 +56,7 @@ namespace glslang { // // Traversal functions for terminals are straighforward.... // -void TIntermMethod::traverse(TIntermTraverser* it) +void TIntermMethod::traverse(TIntermTraverser*) { // Tree should always resolve all methods as a non-method. } diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index e37830d..43836f2 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -891,7 +891,7 @@ TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expres // This is to be executed after the final root is put on top by the parsing // process. // -bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language) +bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/) { if (root == 0) return true; @@ -968,7 +968,7 @@ void TIntermediate::addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymb // Add a caller->callee relationship to the call graph. // Assumes the strings are unique per signature. // -void TIntermediate::addToCallGraph(TInfoSink& infoSink, const TString& caller, const TString& callee) +void TIntermediate::addToCallGraph(TInfoSink& /*infoSink*/, const TString& caller, const TString& callee) { // Duplicates are okay, but faster to not keep them, and they come grouped by caller, // as long as new ones are push on the same end we check on for duplicates diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index a9f9e6c..d5d4135 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -536,7 +536,7 @@ void TParseContext::checkIndex(TSourceLoc loc, const TType& type, int& index) } // for ES 2.0 (version 100) limitations for almost all index operations except vertex-shader uniforms -void TParseContext::handleIndexLimits(TSourceLoc loc, TIntermTyped* base, TIntermTyped* index) +void TParseContext::handleIndexLimits(TSourceLoc /*loc*/, TIntermTyped* base, TIntermTyped* index) { if ((! limits.generalSamplerIndexing && base->getBasicType() == EbtSampler) || (! limits.generalUniformIndexing && base->getQualifier().isUniformOrBuffer() && language != EShLangVertex) || @@ -611,7 +611,7 @@ void TParseContext::ioArrayCheck(TSourceLoc loc, const TType& type, const TStrin // Handle a dereference of a geometry shader input array or tessellation control output array. // See ioArraySymbolResizeList comment in ParseHelper.h. // -void TParseContext::handleIoResizeArrayAccess(TSourceLoc loc, TIntermTyped* base) +void TParseContext::handleIoResizeArrayAccess(TSourceLoc /*loc*/, TIntermTyped* base) { TIntermSymbol* symbolNode = base->getAsSymbolNode(); assert(symbolNode); @@ -645,6 +645,8 @@ void TParseContext::checkIoArraysConsistency(TSourceLoc loc, bool tailOnly) feature = TQualifier::getGeometryString(intermediate.getInputPrimitive()); else if (language == EShLangTessControl) feature = "vertices"; + else + feature = "unknown"; if (tailOnly) { checkIoArrayConsistency(loc, requiredSize, feature, ioArraySymbolResizeList.back()->getWritableType(), ioArraySymbolResizeList.back()->getName()); @@ -1408,7 +1410,7 @@ TOperator TParseContext::mapTypeToConstructorOp(const TType& type) const if (type.isStruct()) return EOpConstructStruct; - TOperator op; + TOperator op = EOpNull; switch (type.getBasicType()) { case EbtFloat: if (type.isMatrix()) { @@ -1515,7 +1517,6 @@ TOperator TParseContext::mapTypeToConstructorOp(const TType& type) const } break; default: - op = EOpNull; break; } @@ -1930,7 +1931,7 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio return true; } - if (op == EOpConstructStruct && ! type.isArray() && type.getStruct()->size() != function.getParamCount()) { + if (op == EOpConstructStruct && ! type.isArray() && (int)type.getStruct()->size() != function.getParamCount()) { error(loc, "Number of constructor parameters does not match the number of structure fields", "constructor", ""); return true; } @@ -2228,7 +2229,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual dst.precision = src.precision; // Layout qualifiers - mergeObjectLayoutQualifiers(loc, dst, src, false); + mergeObjectLayoutQualifiers(dst, src, false); // individual qualifiers bool repeated = false; @@ -2422,7 +2423,7 @@ void TParseContext::arraySizeRequiredCheck(TSourceLoc loc, int size) } } -void TParseContext::structArrayCheck(TSourceLoc loc, TType* type) +void TParseContext::structArrayCheck(TSourceLoc /*loc*/, TType* type) { const TTypeList& structure = *type->getStruct(); for (int m = 0; m < (int)structure.size(); ++m) { @@ -2545,7 +2546,7 @@ void TParseContext::updateImplicitArraySize(TSourceLoc loc, TIntermNode *node, i // as that type will be shared through shallow copies for future references. TSymbol* symbol = 0; int blockIndex = -1; - const TString* lookupName; + const TString* lookupName = 0; if (node->getAsSymbolNode()) lookupName = &node->getAsSymbolNode()->getName(); else if (node->getAsBinaryNode()) { @@ -2782,7 +2783,7 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList // look for match bool found = false; TTypeList::const_iterator newMember; - TSourceLoc memberLoc; + TSourceLoc memberLoc = {}; for (newMember = newTypeList.begin(); newMember != newTypeList.end(); ++newMember) { if (member->type->getFieldName() == newMember->type->getFieldName()) { found = true; @@ -2935,7 +2936,7 @@ void TParseContext::opaqueCheck(TSourceLoc loc, const TType& type, const char* o error(loc, "can't use with samplers or structs containing samplers", op, ""); } -void TParseContext::structTypeCheck(TSourceLoc loc, TPublicType& publicType) +void TParseContext::structTypeCheck(TSourceLoc /*loc*/, TPublicType& publicType) { const TTypeList& typeList = *publicType.userDef->getStruct(); @@ -2982,7 +2983,7 @@ void TParseContext::inductiveLoopCheck(TSourceLoc loc, TIntermNode* init, TInter bool badInit = false; if (! init || ! init->getAsAggregate() || init->getAsAggregate()->getSequence().size() != 1) badInit = true; - TIntermBinary* binaryInit; + TIntermBinary* binaryInit = 0; if (! badInit) { // get the declaration assignment binaryInit = init->getAsAggregate()->getSequence()[0]->getAsBinaryNode(); @@ -3457,7 +3458,7 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType, // overrides the other (e.g., row_major vs. column_major); only the last // occurrence has any effect." // -void TParseContext::mergeObjectLayoutQualifiers(TSourceLoc loc, TQualifier& dst, const TQualifier& src, bool inheritOnly) +void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifier& src, bool inheritOnly) { if (src.hasMatrix()) dst.layoutMatrix = src.layoutMatrix; @@ -3853,8 +3854,6 @@ const TFunction* TParseContext::findFunction(TSourceLoc loc, const TFunction& ca // Function finding algorithm for ES and desktop 110. const TFunction* TParseContext::findFunctionExact(TSourceLoc loc, const TFunction& call, bool& builtIn) { - const TFunction* function = 0; - TSymbol* symbol = symbolTable.find(call.getMangledName(), &builtIn); if (symbol == 0) { error(loc, "no matching overloaded function found", call.getName().c_str(), ""); @@ -3886,7 +3885,6 @@ const TFunction* TParseContext::findFunction120(TSourceLoc loc, const TFunction& TVector candidateList; symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn); - int numPossibleMatches = 0; for (TVector::const_iterator it = candidateList.begin(); it != candidateList.end(); ++it) { const TFunction& function = *(*it); @@ -4034,7 +4032,7 @@ TIntermNode* TParseContext::declareVariable(TSourceLoc loc, TString& identifier, error(loc, "initializer requires a variable, not a member", identifier.c_str(), ""); return 0; } - initNode = executeInitializer(loc, identifier, initializer, variable); + initNode = executeInitializer(loc, initializer, variable); } // look for errors in layout qualifier use @@ -4068,7 +4066,6 @@ void TParseContext::inheritGlobalDefaults(TQualifier& dst) const TVariable* TParseContext::makeInternalVariable(const char* name, const TType& type) const { TString* nameString = new TString(name); - TSourceLoc loc = {0, 0}; TVariable* variable = new TVariable(nameString, type); symbolTable.makeInternalVariable(*variable); @@ -4103,8 +4100,7 @@ TVariable* TParseContext::declareNonArray(TSourceLoc loc, TString& identifier, T // Returning 0 just means there is no code to execute to handle the // initializer, which will, for example, be the case for constant initializers. // -TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TString& identifier, - TIntermTyped* initializer, TVariable* variable) +TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TIntermTyped* initializer, TVariable* variable) { // // Identifier must be of type constant, a global, or a temporary, and @@ -4241,7 +4237,7 @@ TIntermTyped* TParseContext::convertInitializerList(TSourceLoc loc, const TType& return 0; } } else if (type.isMatrix()) { - if (type.getMatrixCols() != initList->getSequence().size()) { + if (type.getMatrixCols() != (int)initList->getSequence().size()) { error(loc, "wrong number of matrix columns:", "initializer list", type.getCompleteString().c_str()); return 0; } @@ -4252,7 +4248,7 @@ TIntermTyped* TParseContext::convertInitializerList(TSourceLoc loc, const TType& return 0; } } else if (type.isVector()) { - if (type.getVectorSize() != initList->getSequence().size()) { + if (type.getVectorSize() != (int)initList->getSequence().size()) { error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString().c_str()); return 0; } @@ -4546,7 +4542,7 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr // fix and check for member layout qualifiers - mergeObjectLayoutQualifiers(loc, defaultQualification, currentBlockQualifier, true); + mergeObjectLayoutQualifiers(defaultQualification, currentBlockQualifier, true); // "The offset qualifier can only be used on block members of blocks declared with std140 or std430 layouts." // "The align qualifier can only be used on blocks or block members, and only for blocks declared with std140 or std430 layouts." @@ -4605,14 +4601,14 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr // Process the members fixBlockLocations(loc, currentBlockQualifier, typeList, memberWithLocation, memberWithoutLocation); - fixBlockXfbOffsets(loc, currentBlockQualifier, typeList); - fixBlockUniformOffsets(loc, currentBlockQualifier, typeList); + fixBlockXfbOffsets(currentBlockQualifier, typeList); + fixBlockUniformOffsets(currentBlockQualifier, typeList); for (unsigned int member = 0; member < typeList.size(); ++member) layoutTypeCheck(typeList[member].loc, *typeList[member].type); // reverse merge, so that currentBlockQualifier now has all layout information // (can't use defaultQualification directly, it's missing other non-layout-default-class qualifiers) - mergeObjectLayoutQualifiers(loc, currentBlockQualifier, defaultQualification, true); + mergeObjectLayoutQualifiers(currentBlockQualifier, defaultQualification, true); // // Build and add the interface block as a new type named 'blockName' @@ -4696,7 +4692,7 @@ void TParseContext::fixBlockLocations(TSourceLoc loc, TQualifier& qualifier, TTy else { if (memberWithLocation) { // remove any block-level location and make it per *every* member - int nextLocation; // by the rule above, initial value is not relevant + int nextLocation = 0; // by the rule above, initial value is not relevant if (qualifier.hasAnyLocation()) { nextLocation = qualifier.layoutLocation; qualifier.layoutLocation = TQualifier::layoutLocationEnd; @@ -4723,7 +4719,7 @@ void TParseContext::fixBlockLocations(TSourceLoc loc, TQualifier& qualifier, TTy } } -void TParseContext::fixBlockXfbOffsets(TSourceLoc loc, TQualifier& qualifier, TTypeList& typeList) +void TParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeList) { // "If a block is qualified with xfb_offset, all its // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any @@ -4760,7 +4756,7 @@ void TParseContext::fixBlockXfbOffsets(TSourceLoc loc, TQualifier& qualifier, TT // Also, compute and save the total size of the block. For the block's size, arrayness // is not taken into account, as each element is backed by a separate buffer. // -void TParseContext::fixBlockUniformOffsets(TSourceLoc loc, TQualifier& qualifier, TTypeList& typeList) +void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typeList) { if (! qualifier.isUniformOrBuffer()) return; @@ -4950,7 +4946,7 @@ void TParseContext::updateStandaloneQualifierDefaults(TSourceLoc loc, const TPub if (! intermediate.setLocalSize(i, publicType.shaderQualifiers.localSize[i])) error(loc, "cannot change previously set size", "local_size", ""); else { - int max; + int max = 0; switch (i) { case 0: max = resources.maxComputeWorkGroupSizeX; break; case 1: max = resources.maxComputeWorkGroupSizeY; break; diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 388c16b..90b22df 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -160,7 +160,7 @@ public: void setLayoutQualifier(TSourceLoc, TPublicType&, TString&); void setLayoutQualifier(TSourceLoc, TPublicType&, TString&, const TIntermTyped*); - void mergeObjectLayoutQualifiers(TSourceLoc, TQualifier& dest, const TQualifier& src, bool inheritOnly); + void mergeObjectLayoutQualifiers(TQualifier& dest, const TQualifier& src, bool inheritOnly); void layoutObjectCheck(TSourceLoc, const TSymbol&); void layoutTypeCheck(TSourceLoc, const TType&); void layoutQualifierCheck(TSourceLoc, const TQualifier&); @@ -178,8 +178,8 @@ public: TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, TSourceLoc, bool subset); void declareBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0); void fixBlockLocations(TSourceLoc, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation); - void fixBlockXfbOffsets(TSourceLoc, TQualifier&, TTypeList&); - void fixBlockUniformOffsets(TSourceLoc, TQualifier&, TTypeList&); + void fixBlockXfbOffsets(TQualifier&, TTypeList&); + void fixBlockUniformOffsets(TQualifier&, TTypeList&); void addQualifierToExisting(TSourceLoc, TQualifier, const TString& identifier); void addQualifierToExisting(TSourceLoc, TQualifier, TIdentifierList&); void invariantCheck(TSourceLoc, const TQualifier&); @@ -221,7 +221,7 @@ protected: TVariable* makeInternalVariable(const char* name, const TType&) const; TVariable* declareNonArray(TSourceLoc, TString& identifier, TType&, bool& newDeclaration); void declareArray(TSourceLoc, TString& identifier, const TType&, TSymbol*&, bool& newDeclaration); - TIntermNode* executeInitializer(TSourceLoc, TString& identifier, TIntermTyped* initializer, TVariable* variable); + TIntermNode* executeInitializer(TSourceLoc, TIntermTyped* initializer, TVariable* variable); TIntermTyped* convertInitializerList(TSourceLoc, const TType&, TIntermTyped* initializer); TOperator mapTypeToConstructorOp(const TType&) const; void finalErrorCheck(); @@ -263,6 +263,9 @@ public: TLimits& limits; protected: + TParseContext(TParseContext&); + TParseContext& operator=(TParseContext&); + TScanContext* scanContext; TPpContext* ppContext; TInputScanner* currentScanner; diff --git a/glslang/MachineIndependent/PoolAlloc.cpp b/glslang/MachineIndependent/PoolAlloc.cpp index 26b371a..a0d8a7e 100644 --- a/glslang/MachineIndependent/PoolAlloc.cpp +++ b/glslang/MachineIndependent/PoolAlloc.cpp @@ -183,7 +183,11 @@ const unsigned char TAllocation::userDataFill = 0xcd; // // Check a single guard block for damage // +#ifdef GUARD_BLOCKS void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const +#else +void TAllocation::checkGuardBlock(unsigned char*, unsigned char, const char*) const +#endif { #ifdef GUARD_BLOCKS for (int x = 0; x < guardBlockSize; x++) { diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 55ebcea..6c56c1c 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -249,7 +249,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT for (profileLength = 0; profileLength < maxProfileLength; ++profileLength) { if (c < 0 || c == ' ' || c == '\t' || c == '\n' || c == '\r') break; - profileString[profileLength] = c; + profileString[profileLength] = (char)c; c = get(); } if (c > 0 && c != ' ' && c != '\t' && c != '\n' && c != '\r') { @@ -274,6 +274,9 @@ public: explicit TParserToken(YYSTYPE& b) : sType(b) { } YYSTYPE& sType; +protected: + TParserToken(TParserToken&); + TParserToken& operator=(TParserToken&); }; } // end namespace glslang @@ -594,7 +597,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token) default: char buf[2]; - buf[0] = ppToken.token; + buf[0] = (char)ppToken.token; buf[1] = 0; parseContext.error(loc, "unexpected token", buf, ""); break; diff --git a/glslang/MachineIndependent/ScanContext.h b/glslang/MachineIndependent/ScanContext.h index 621c771..5f1ffb5 100644 --- a/glslang/MachineIndependent/ScanContext.h +++ b/glslang/MachineIndependent/ScanContext.h @@ -57,6 +57,9 @@ public: int tokenize(TPpContext*, TParserToken&); protected: + TScanContext(TScanContext&); + TScanContext& operator=(TScanContext&); + int tokenizeIdentifier(); int identifierOrType(); int reservedWord(); diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index 9178df2..cf485bf 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -688,7 +688,7 @@ int ShCompile( const int* inputLengths, const EShOptimizationLevel optLevel, const TBuiltInResource* resources, - int debugOptions, // currently unused + int /*debugOptions*/, int defaultVersion, // use 100 for ES environment, 110 for desktop bool forwardCompatible, // give errors for use of deprecated features EShMessages messages // warnings/errors/AST; things to print out @@ -730,36 +730,6 @@ int ShCompile( // Return: The return value of is really boolean, indicating // success or failure. // -int ShLink( - const ShHandle linkHandle, - const ShHandle compHandles[], - const int numHandles, - ShHandle uniformMapHandle, - short int** uniformsAccessed, - int* numUniformsAccessed) - -{ - if (!InitThread()) - return 0; - - TShHandleBase* base = reinterpret_cast(linkHandle); - TLinker* linker = static_cast(base->getAsLinker()); - if (linker == 0) - return 0; - - int returnValue; - GetThreadPoolAllocator().push(); - returnValue = ShLinkExt(linkHandle, compHandles, numHandles); - GetThreadPoolAllocator().pop(); - - if (returnValue) - return 1; - - return 0; -} -// -// This link method will be eventually used once the ICD supports the new linker interface -// int ShLinkExt( const ShHandle linkHandle, const ShHandle compHandles[], @@ -835,6 +805,8 @@ const char* ShGetInfoLog(const ShHandle handle) infoSink = &(base->getAsCompiler()->getInfoSink()); else if (base->getAsLinker()) infoSink = &(base->getAsLinker()->getInfoSink()); + else + return 0; infoSink->info << infoSink->debug.c_str(); return infoSink->info.c_str(); @@ -990,7 +962,7 @@ void FinalizeProcess() class TDeferredCompiler : public TCompiler { public: TDeferredCompiler(EShLanguage s, TInfoSink& i) : TCompiler(s, i) { } - virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile) { return true; } + virtual bool compile(TIntermNode*, int = 0, EProfile = ENoProfile) { return true; } }; TShader::TShader(EShLanguage s) diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index f398acf..148590f 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -1027,7 +1027,7 @@ layout_qualifier_id_list | layout_qualifier_id_list COMMA layout_qualifier_id { $$ = $1; $$.shaderQualifiers.merge($3.shaderQualifiers); - parseContext.mergeObjectLayoutQualifiers($2.loc, $$.qualifier, $3.qualifier, false); + parseContext.mergeObjectLayoutQualifiers($$.qualifier, $3.qualifier, false); } layout_qualifier_id diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index 681a9ee..000ee10 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -67,6 +67,9 @@ public: virtual bool visitSwitch(TVisit, TIntermSwitch* node); TInfoSink& infoSink; +protected: + TOutputTraverser(TOutputTraverser&); + TOutputTraverser& operator=(TOutputTraverser&); }; // diff --git a/glslang/MachineIndependent/limits.cpp b/glslang/MachineIndependent/limits.cpp index 08f873b..4573d28 100644 --- a/glslang/MachineIndependent/limits.cpp +++ b/glslang/MachineIndependent/limits.cpp @@ -74,6 +74,10 @@ public: TSymbolTable& symbolTable; bool bad; TSourceLoc badLoc; + +protected: + TInductiveTraverser(TInductiveTraverser&); + TInductiveTraverser& operator=(TInductiveTraverser&); }; // check binary operations for those modifying the loop index @@ -152,6 +156,10 @@ public: const TIdSetType& inductiveLoopIds; bool bad; TSourceLoc badLoc; + +protected: + TIndexTraverser(TIndexTraverser&); + TIndexTraverser& operator=(TIndexTraverser&); }; // make sure symbols are inductive-loop indexes diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index db60a06..51364c2 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -285,7 +285,7 @@ public: int addUsedOffsets(int binding, int offset, int numOffsets); int computeTypeLocationSize(const TType&) const; - bool setXfbBufferStride(int buffer, int stride) + bool setXfbBufferStride(int buffer, unsigned stride) { if (xfbBuffers[buffer].stride != TQualifier::layoutXfbStrideEnd) return xfbBuffers[buffer].stride == stride; diff --git a/glslang/MachineIndependent/parseConst.cpp b/glslang/MachineIndependent/parseConst.cpp index 978dc8a..90621d3 100644 --- a/glslang/MachineIndependent/parseConst.cpp +++ b/glslang/MachineIndependent/parseConst.cpp @@ -62,6 +62,10 @@ public: bool isMatrix; int matrixCols; int matrixRows; + +protected: + TConstTraverser(TConstTraverser&); + TConstTraverser& operator=(TConstTraverser&); }; bool TConstTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node) diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 85f24f8..4b04fed 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -454,8 +454,8 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo return token; } - Symbol* s; - res = (s = LookUpSymbol(ppToken->atom)) ? !s->mac.undef : 0; + Symbol* s = LookUpSymbol(ppToken->atom); + res = s ? ! s->mac.undef : 0; token = scanToken(ppToken); if (needclose) { if (token != ')') { @@ -690,8 +690,6 @@ int TPpContext::CPPerror(TPpToken* ppToken) int TPpContext::CPPpragma(TPpToken* ppToken) { char SrcStrName[2]; - int tokenCount = 0; - int maxTokenCount = 10; const char* SrcStr; TVector tokens; @@ -711,7 +709,7 @@ int TPpContext::CPPpragma(TPpToken* ppToken) tokens.push_back(SrcStr); break; default: - SrcStrName[0] = token; + SrcStrName[0] = (char)token; SrcStrName[1] = '\0'; tokens.push_back(SrcStrName); } @@ -887,7 +885,7 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream* a, TPpToken* p n = new TokenStream; pushInput(new tMarkerInput(this)); - pushTokenStreamInput(a, 0); + pushTokenStreamInput(a); while ((token = scanToken(ppToken)) != tMarkerInput::marker) { if (token == CPP_IDENTIFIER && MacroExpand(ppToken->atom, ppToken, false, newLineOkay) != 0) continue; @@ -916,7 +914,7 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken) if (mac->args[i] == ppToken->atom) break; if (i >= 0) { - pp->pushTokenStreamInput(args[i], ppToken->atom); + pp->pushTokenStreamInput(args[i]); return pp->scanToken(ppToken); } diff --git a/glslang/MachineIndependent/preprocessor/PpContext.cpp b/glslang/MachineIndependent/preprocessor/PpContext.cpp index 862086e..41d7f4e 100644 --- a/glslang/MachineIndependent/preprocessor/PpContext.cpp +++ b/glslang/MachineIndependent/preprocessor/PpContext.cpp @@ -87,7 +87,7 @@ TPpContext::TPpContext(TParseContext& pc) : preamble(0), strings(0), parseContext(pc), inComment(false) { InitAtomTable(); - InitScanner(this); + InitScanner(); ifdepth = 0; for (elsetracker = 0; elsetracker < maxIfNesting; elsetracker++) diff --git a/glslang/MachineIndependent/preprocessor/PpContext.h b/glslang/MachineIndependent/preprocessor/PpContext.h index fabe7ce..0a1c2b3 100644 --- a/glslang/MachineIndependent/preprocessor/PpContext.h +++ b/glslang/MachineIndependent/preprocessor/PpContext.h @@ -193,6 +193,9 @@ public: TSymbolMap symbols; // this has light use... just defined macros protected: + TPpContext(TPpContext&); + TPpContext& operator=(TPpContext&); + char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble int preambleLength; char** strings; // official strings of shader, starting a string 0 line 1 @@ -342,7 +345,7 @@ protected: void RecordToken(TokenStream* pTok, int token, TPpToken* ppToken); void RewindTokenStream(TokenStream *pTok); int ReadToken(TokenStream* pTok, TPpToken* ppToken); - void pushTokenStreamInput(TokenStream *ts, int name); + void pushTokenStreamInput(TokenStream *ts); void UngetToken(int token, TPpToken* ppToken); class tTokenInput : public tInput { @@ -445,7 +448,7 @@ protected: TInputScanner* input; }; - int InitScanner(TPpContext* cpp); + int InitScanner(); int ScanFromString(char* s); void missingEndifCheck(); int lFloatConst(int len, int ch, TPpToken* ppToken); diff --git a/glslang/MachineIndependent/preprocessor/PpMemory.cpp b/glslang/MachineIndependent/preprocessor/PpMemory.cpp index b71d2cf..4448a4b 100644 --- a/glslang/MachineIndependent/preprocessor/PpMemory.cpp +++ b/glslang/MachineIndependent/preprocessor/PpMemory.cpp @@ -95,8 +95,6 @@ struct chunk { TPpContext::MemoryPool* TPpContext::mem_CreatePool(size_t chunksize, unsigned int align) { - MemoryPool *pool; - if (align == 0) align = ALIGN; if (chunksize == 0) @@ -107,7 +105,9 @@ TPpContext::MemoryPool* TPpContext::mem_CreatePool(size_t chunksize, unsigned in return 0; if (chunksize & (align - 1)) return 0; - if (!(pool = (MemoryPool*)malloc(chunksize))) + + MemoryPool *pool = (MemoryPool*)malloc(chunksize); + if (! pool) return 0; pool->next = 0; diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp index e0f3b55..5c301d3 100644 --- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -92,7 +92,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace glslang { -int TPpContext::InitScanner(TPpContext *cpp) +int TPpContext::InitScanner() { // Add various atoms needed by the CPP line scanner: if (!InitCPP()) @@ -127,13 +127,13 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) char* str = ppToken->name; if (ch == '.') { HasDecimalOrExponent = true; - str[len++]=ch; + str[len++] = (char)ch; ch = getChar(); while (ch >= '0' && ch <= '9') { if (len < TPpToken::maxTokenLength) { declen++; if (len > 0 || ch != '0') { - str[len] = ch; + str[len] = (char)ch; len++; str_len++; } @@ -155,21 +155,21 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) len = 1,str_len=1; } else { ExpSign = 1; - str[len++]=ch; + str[len++] = (char)ch; ch = getChar(); if (ch == '+') { - str[len++]=ch; + str[len++] = (char)ch; ch = getChar(); } else if (ch == '-') { ExpSign = -1; - str[len++]=ch; + str[len++] = (char)ch; ch = getChar(); } if (ch >= '0' && ch <= '9') { while (ch >= '0' && ch <= '9') { if (len < TPpToken::maxTokenLength) { exp = exp*10 + ch - '0'; - str[len++]=ch; + str[len++] = (char)ch; ch = getChar(); } else { parseContext.error(ppToken->loc, "float literal too long", "", ""); @@ -197,8 +197,8 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) ungetChar(); } else { if (len < TPpToken::maxTokenLength) { - str[len++] = ch; - str[len++] = ch2; + str[len++] = (char)ch; + str[len++] = (char)ch2; isDouble = 1; } else { parseContext.error(ppToken->loc, "float literal too long", "", ""); @@ -212,7 +212,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken) if (! HasDecimalOrExponent) parseContext.error(ppToken->loc, "float literal needs a decimal point or exponent", "", ""); if (len < TPpToken::maxTokenLength) - str[len++] = ch; + str[len++] = (char)ch; else { parseContext.error(ppToken->loc, "float literal too long", "", ""); len = 1,str_len=1; @@ -238,7 +238,9 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) { char tokenText[TPpToken::maxTokenLength + 1]; int AlreadyComplained = 0; - int len, ch, ii; + int len = 0; + int ch = 0; + int ii = 0; unsigned ival = 0; ppToken->ival = 0; @@ -273,7 +275,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) case 'z': do { if (len < TPpToken::maxTokenLength) { - tokenText[len++] = ch; + tokenText[len++] = (char)ch; ch = pp->getChar(); } else { if (! AlreadyComplained) { @@ -297,13 +299,13 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) return CPP_IDENTIFIER; case '0': - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; ch = pp->getChar(); if (ch == 'x' || ch == 'X') { // must be hexidecimal bool isUnsigned = false; - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; ch = pp->getChar(); if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || @@ -312,7 +314,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ival = 0; do { if (ival <= 0x0fffffff) { - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; if (ch >= '0' && ch <= '9') { ii = ch - '0'; } else if (ch >= 'A' && ch <= 'F') { @@ -338,7 +340,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) } if (ch == 'u' || ch == 'U') { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; isUnsigned = true; } else pp->ungetChar(); @@ -360,7 +362,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) // see how much octal-like stuff we can read while (ch >= '0' && ch <= '7') { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { pp->parseContext.error(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; @@ -378,7 +380,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) nonOctal = true; do { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { pp->parseContext.error(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; @@ -395,7 +397,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) if (ch == 'u' || ch == 'U') { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; isUnsigned = true; } else pp->ungetChar(); @@ -418,7 +420,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) do { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; else if (! AlreadyComplained) { pp->parseContext.error(ppToken->loc, "numeric literal too long", "", ""); AlreadyComplained = 1; @@ -433,7 +435,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) int uint = 0; if (ch == 'u' || ch == 'U') { if (len < TPpToken::maxTokenLength) - ppToken->name[len++] = ch; + ppToken->name[len++] = (char)ch; uint = 1; } else pp->ungetChar(); @@ -442,9 +444,9 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ival = 0; for (ii = 0; ii < numericLen; ii++) { ch = ppToken->name[ii] - '0'; - if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) { + if ((ival > 0x19999999u) || (ival == 0x19999999u && ch >= 6)) { pp->parseContext.error(ppToken->loc, "numeric literal too big", "", ""); - ival = -1; + ival = 0xFFFFFFFFu; break; } else ival = ival * 10 + ch; @@ -651,7 +653,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ch = pp->getChar(); while (ch != '"' && ch != '\n' && ch != EOF) { if (len < TPpToken::maxTokenLength) { - tokenText[len] = ch; + tokenText[len] = (char)ch; len++; ch = pp->getChar(); } else diff --git a/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/glslang/MachineIndependent/preprocessor/PpTokens.cpp index b7cc0d3..794cb24 100644 --- a/glslang/MachineIndependent/preprocessor/PpTokens.cpp +++ b/glslang/MachineIndependent/preprocessor/PpTokens.cpp @@ -197,7 +197,7 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken) ch = lReadByte(pTok); while (ch != 0) { if (len < TPpToken::maxTokenLength) { - tokenText[len] = ch; + tokenText[len] = (char)ch; len++; ch = lReadByte(pTok); } else { @@ -239,7 +239,7 @@ int TPpContext::tTokenInput::scan(TPpToken* ppToken) return pp->ReadToken(tokens, ppToken); } -void TPpContext::pushTokenStreamInput(TokenStream* ts, int name) +void TPpContext::pushTokenStreamInput(TokenStream* ts) { pushInput(new tTokenInput(this, ts)); RewindTokenStream(ts); diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index fa5a912..60b04ba 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -618,6 +618,10 @@ public: const TIntermediate& intermediate; TReflection& reflection; std::set processedDerefs; + +protected: + TLiveTraverser(TLiveTraverser&); + TLiveTraverser& operator=(TLiveTraverser&); }; //