Make some portability improvements identified by Christophe: A few size_t, a couple "../Include", and a whole bunch of parenthesizing "(A && B) || (C && D)", because some compilers don't believe humans know && is higher precedence than ||.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23379 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-10-04 02:27:06 +00:00
parent 61c2d1410a
commit e50441ad94
12 changed files with 106 additions and 105 deletions

View File

@ -32,7 +32,7 @@
//POSSIBILITY OF SUCH DAMAGE. //POSSIBILITY OF SUCH DAMAGE.
// //
#include "Include/InfoSink.h" #include "../Include/InfoSink.h"
#include <string.h> #include <string.h>

View File

@ -53,7 +53,7 @@ TBuiltIns::TBuiltIns()
prefixes[EbtFloat] = ""; prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i"; prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u"; prefixes[EbtUint] = "u";
postfixes[2] = "2"; postfixes[2] = "2";
postfixes[3] = "3"; postfixes[3] = "3";
postfixes[4] = "4"; postfixes[4] = "4";
@ -399,8 +399,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("bvec4 isinf(vec4 x);"); s.append("bvec4 isinf(vec4 x);");
} }
if (profile == EEsProfile && version >= 300 || if ((profile == EEsProfile && version >= 300) ||
profile != EEsProfile && version >= 330) { (profile != EEsProfile && version >= 330)) {
s.append("int floatBitsToInt(float value);"); s.append("int floatBitsToInt(float value);");
s.append("ivec2 floatBitsToInt(vec2 value);"); s.append("ivec2 floatBitsToInt(vec2 value);");
s.append("ivec3 floatBitsToInt(vec3 value);"); s.append("ivec3 floatBitsToInt(vec3 value);");
@ -422,8 +422,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("vec4 uintBitsToFloat(uvec4 value);"); s.append("vec4 uintBitsToFloat(uvec4 value);");
} }
if (profile == EEsProfile && version >= 300 || if ((profile == EEsProfile && version >= 300) ||
profile != EEsProfile && version >= 400) { (profile != EEsProfile && version >= 400)) {
s.append( "highp uint packSnorm2x16 (vec2);"); s.append( "highp uint packSnorm2x16 (vec2);");
s.append( "highp vec2 unpackSnorm2x16 (highp uint);"); s.append( "highp vec2 unpackSnorm2x16 (highp uint);");
s.append( "highp uint packUnorm2x16 (vec2);"); s.append( "highp uint packUnorm2x16 (vec2);");
@ -503,7 +503,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("float determinant(mat2 m);"); s.append("float determinant(mat2 m);");
s.append("float determinant(mat3 m);"); s.append("float determinant(mat3 m);");
s.append("float determinant(mat4 m);"); s.append("float determinant(mat4 m);");
s.append("mat2 inverse(mat2 m);"); s.append("mat2 inverse(mat2 m);");
s.append("mat3 inverse(mat3 m);"); s.append("mat3 inverse(mat3 m);");
s.append("mat4 inverse(mat4 m);"); s.append("mat4 inverse(mat4 m);");
@ -587,8 +587,9 @@ void TBuiltIns::initialize(int version, EProfile profile)
// Original-style texture functions existing in both stages. // Original-style texture functions existing in both stages.
// (Per-stage functions below.) // (Per-stage functions below.)
// //
if (profile == EEsProfile && version == 100 || if ((profile == EEsProfile && version == 100) ||
profile == ECompatibilityProfile || version < FirstProfileVersion) { profile == ECompatibilityProfile ||
version < FirstProfileVersion) {
s.append("vec4 texture2D(sampler2D, vec2);"); s.append("vec4 texture2D(sampler2D, vec2);");
s.append("vec4 texture2DProj(sampler2D, vec3);"); s.append("vec4 texture2DProj(sampler2D, vec3);");
@ -597,13 +598,13 @@ void TBuiltIns::initialize(int version, EProfile profile)
s.append("vec4 textureCube(samplerCube, vec3);"); s.append("vec4 textureCube(samplerCube, vec3);");
} }
if (profile != EEsProfile && if (profile != EEsProfile &&
(profile == ECompatibilityProfile || version < FirstProfileVersion)) { (profile == ECompatibilityProfile || version < FirstProfileVersion)) {
s.append("vec4 texture1D(sampler1D, float);"); s.append("vec4 texture1D(sampler1D, float);");
s.append("vec4 texture1DProj(sampler1D, vec2);"); s.append("vec4 texture1DProj(sampler1D, vec2);");
s.append("vec4 texture1DProj(sampler1D, vec4);"); s.append("vec4 texture1DProj(sampler1D, vec4);");
s.append("vec4 texture3D(sampler3D, vec3);"); s.append("vec4 texture3D(sampler3D, vec3);");
s.append("vec4 texture3DProj(sampler3D, vec4);"); s.append("vec4 texture3DProj(sampler3D, vec4);");
@ -1016,7 +1017,7 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
// enumerate all the types // enumerate all the types
for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler
if (image > 0 && version < 420) if (image > 0 && version < 420)
continue; continue;
@ -1055,11 +1056,11 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
// //
// Now, make all the function prototypes for the type we just built... // Now, make all the function prototypes for the type we just built...
// //
TSampler sampler; TSampler sampler;
sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false, sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
shadow ? true : false, shadow ? true : false,
ms ? true : false); ms ? true : false);
if (image) if (image)
sampler.image = true; sampler.image = true;
@ -1067,10 +1068,10 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
TString typeName = sampler.getString(); TString typeName = sampler.getString();
addQueryFunctions(sampler, typeName, version, profile); addQueryFunctions(sampler, typeName, version, profile);
if (image) if (image)
addImageFunctions(sampler, typeName, version, profile); addImageFunctions(sampler, typeName, version, profile);
else else
addSamplingFunctions(sampler, typeName, version, profile); addSamplingFunctions(sampler, typeName, version, profile);
} }
} }
@ -1192,7 +1193,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
continue; continue;
if (extraProj && (sampler.dim == Esd3D || sampler.shadow)) if (extraProj && (sampler.dim == Esd3D || sampler.shadow))
continue; continue;
TString s; TString s;
// return type // return type
@ -1229,14 +1230,14 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
else { else {
s.append(","); s.append(",");
TBasicType t = fetch ? EbtInt : EbtFloat; TBasicType t = fetch ? EbtInt : EbtFloat;
if (totalDims == 1) if (totalDims == 1)
s.append(TType::getBasicString(t)); s.append(TType::getBasicString(t));
else { else {
s.append(prefixes[t]); s.append(prefixes[t]);
s.append("vec"); s.append("vec");
s.append(postfixes[totalDims]); s.append(postfixes[totalDims]);
} }
} }
if (bias && compare) if (bias && compare)
continue; continue;
@ -1331,7 +1332,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
s.append(builtInConstant); s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors); snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
s.append(builtInConstant); s.append(builtInConstant);
@ -1350,7 +1351,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset); snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
s.append(builtInConstant); s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset); snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
s.append(builtInConstant); s.append(builtInConstant);
} }
@ -1507,7 +1508,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
case EShLangCompute: case EShLangCompute:
// TODO: desktop functionality: support new stages // TODO: desktop functionality: support new stages
break; break;
default: default:
assert(false && "Language not supported"); assert(false && "Language not supported");
break; break;
@ -1526,7 +1527,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.relateToOperator("outerProduct", EOpOuterProduct); symbolTable.relateToOperator("outerProduct", EOpOuterProduct);
symbolTable.relateToOperator("transpose", EOpTranspose); symbolTable.relateToOperator("transpose", EOpTranspose);
if (version >= 150) { if (version >= 150) {
symbolTable.relateToOperator("determinant", EOpDeterminant); symbolTable.relateToOperator("determinant", EOpDeterminant);
symbolTable.relateToOperator("inverse", EOpMatrixInverse); symbolTable.relateToOperator("inverse", EOpMatrixInverse);
} }
} }
@ -1637,7 +1638,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier); symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
break; break;
default: default:
assert(false && "Language not supported"); assert(false && "Language not supported");
} }
} }

View File

@ -37,7 +37,7 @@
#ifndef _INITIALIZE_INCLUDED_ #ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_ #define _INITIALIZE_INCLUDED_
#include "Include/ResourceLimits.h" #include "../Include/ResourceLimits.h"
#include "../Include/Common.h" #include "../Include/Common.h"
#include "../Include/ShHandle.h" #include "../Include/ShHandle.h"
#include "SymbolTable.h" #include "SymbolTable.h"

View File

@ -645,7 +645,7 @@ TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* r
{ {
TIntermAggregate* aggNode = growAggregate(left, right); TIntermAggregate* aggNode = growAggregate(left, right);
if (aggNode) if (aggNode)
aggNode->setLoc(loc); aggNode->setLoc(loc);
return aggNode; return aggNode;
} }
@ -926,8 +926,8 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
numErrors += unit.numErrors; numErrors += unit.numErrors;
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end()); callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
if (profile != EEsProfile && unit.profile == EEsProfile || if ((profile != EEsProfile && unit.profile == EEsProfile) ||
profile == EEsProfile && unit.profile != EEsProfile) (profile == EEsProfile && unit.profile != EEsProfile))
error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n"); error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n");
if (unit.treeRoot == 0) if (unit.treeRoot == 0)
@ -985,10 +985,10 @@ void TIntermediate::mergeBodies(TInfoSink& infoSink, TIntermSequence& globals, c
void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects) void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects)
{ {
// Error check and merge the linker objects (duplicates should not be merged) // Error check and merge the linker objects (duplicates should not be merged)
unsigned int initialNumLinkerObjects = linkerObjects.size(); std::size_t initialNumLinkerObjects = linkerObjects.size();
for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) { for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) {
bool merge = true; bool merge = true;
for (unsigned int linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) { for (std::size_t linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode(); TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode();
TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode(); TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
assert(symbol && unitSymbol); assert(symbol && unitSymbol);
@ -1379,8 +1379,8 @@ bool TIntermBinary::promote()
case EOpInclusiveOrAssign: case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign: case EOpExclusiveOrAssign:
// Check for integer-only operands. // Check for integer-only operands.
if ( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint || if (( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint) ||
right->getBasicType() != EbtInt && right->getBasicType() != EbtUint) (right->getBasicType() != EbtInt && right->getBasicType() != EbtUint))
return false; return false;
if (left->isMatrix() || right->isMatrix()) if (left->isMatrix() || right->isMatrix())
return false; return false;
@ -1557,8 +1557,8 @@ bool TIntermBinary::promote()
case EOpSubAssign: case EOpSubAssign:
case EOpDivAssign: case EOpDivAssign:
case EOpModAssign: case EOpModAssign:
if (left->isMatrix() && right->isVector() || if ((left->isMatrix() && right->isVector()) ||
left->isVector() && right->isMatrix() || (left->isVector() && right->isMatrix()) ||
left->getBasicType() != right->getBasicType()) left->getBasicType() != right->getBasicType())
return false; return false;
if (left->isMatrix() && right->isMatrix() && (left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows())) if (left->isMatrix() && right->isMatrix() && (left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows()))

View File

@ -119,7 +119,7 @@ const char* TParseContext::getPreamble()
// //
// Returns true for successful acceptance of the shader, false if any errors. // Returns true for successful acceptance of the shader, false if any errors.
// //
bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], int lengths[], int numStrings) bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], size_t lengths[], int numStrings)
{ {
// empty shaders are okay // empty shaders are okay
if (! strings || numStrings == 0 || lengths[0] == 0) if (! strings || numStrings == 0 || lengths[0] == 0)
@ -141,7 +141,7 @@ bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], i
ppContext.setShaderStrings(strings, lengths, numStrings); ppContext.setShaderStrings(strings, lengths, numStrings);
// TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens // TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens
int len = 0; size_t len = 0;
while (strings[0][len] == ' ' || while (strings[0][len] == ' ' ||
strings[0][len] == '\t' || strings[0][len] == '\t' ||
strings[0][len] == '\n' || strings[0][len] == '\n' ||
@ -469,8 +469,8 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
} else { } else {
if (index->getQualifier().storage == EvqConst) { if (index->getQualifier().storage == EvqConst) {
int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst(); int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
if (! base->isArray() && (base->isVector() && base->getType().getVectorSize() <= indexValue || if (! base->isArray() && ((base->isVector() && base->getType().getVectorSize() <= indexValue) ||
base->isMatrix() && base->getType().getMatrixCols() <= indexValue)) (base->isMatrix() && base->getType().getMatrixCols() <= indexValue)))
error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst()); error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst());
if (base->isArray()) { if (base->isArray()) {
if (base->getType().getArraySize() == 0) { if (base->getType().getArraySize() == 0) {
@ -1441,8 +1441,8 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) { if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) {
profileRequires(loc, EEsProfile, 300, 0, "shader input/output"); profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat || if ((language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat) ||
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) { (language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat)) {
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType)); error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
return; return;
@ -1496,11 +1496,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Storage qualification // Storage qualification
if (dst.storage == EvqTemporary || dst.storage == EvqGlobal) if (dst.storage == EvqTemporary || dst.storage == EvqGlobal)
dst.storage = src.storage; dst.storage = src.storage;
else if (dst.storage == EvqIn && src.storage == EvqOut || else if ((dst.storage == EvqIn && src.storage == EvqOut) ||
dst.storage == EvqOut && src.storage == EvqIn) (dst.storage == EvqOut && src.storage == EvqIn))
dst.storage = EvqInOut; dst.storage = EvqInOut;
else if (dst.storage == EvqIn && src.storage == EvqConst || else if ((dst.storage == EvqIn && src.storage == EvqConst) ||
dst.storage == EvqConst && src.storage == EvqIn) (dst.storage == EvqConst && src.storage == EvqIn))
dst.storage = EvqConstReadOnly; dst.storage = EvqConstReadOnly;
else if (src.storage != EvqTemporary) else if (src.storage != EvqTemporary)
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), ""); error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
@ -1508,7 +1508,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Precision qualifiers // Precision qualifiers
if (! force && src.precision != EpqNone && dst.precision != EpqNone) if (! force && src.precision != EpqNone && dst.precision != EpqNone)
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), ""); error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
if (dst.precision == EpqNone || force && src.precision != EpqNone) if (dst.precision == EpqNone || (force && src.precision != EpqNone))
dst.precision = src.precision; dst.precision = src.precision;
// Layout qualifiers // Layout qualifiers
@ -1678,16 +1678,16 @@ void TParseContext::arrayDimError(TSourceLoc loc)
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2) void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
{ {
if (sizes1 && sizes2 || if ((sizes1 && sizes2) ||
sizes1 && sizes1->isArrayOfArrays() || (sizes1 && sizes1->isArrayOfArrays()) ||
sizes2 && sizes2->isArrayOfArrays()) (sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc); arrayDimError(loc);
} }
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2) void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
{ {
if (type && type->isArray() && sizes2 || if ((type && type->isArray() && sizes2) ||
sizes2 && sizes2->isArrayOfArrays()) (sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc); arrayDimError(loc);
} }
@ -1815,18 +1815,18 @@ TVariable* TParseContext::redeclareBuiltin(TSourceLoc loc, const TString& identi
// Potentially redeclaring a built-in variable... // Potentially redeclaring a built-in variable...
if (identifier == "gl_FragDepth" && version >= 420 || if ((identifier == "gl_FragDepth" && version >= 420) ||
identifier == "gl_PerVertex" && version >= 410 || (identifier == "gl_PerVertex" && version >= 410) ||
identifier == "gl_PerFragment" && version >= 410 || (identifier == "gl_PerFragment" && version >= 410) ||
identifier == "gl_FragCoord" && version >= 150 || (identifier == "gl_FragCoord" && version >= 150) ||
identifier == "gl_ClipDistance" && version >= 130 || (identifier == "gl_ClipDistance" && version >= 130) ||
identifier == "gl_FrontColor" && version >= 130 || (identifier == "gl_FrontColor" && version >= 130) ||
identifier == "gl_BackColor" && version >= 130 || (identifier == "gl_BackColor" && version >= 130) ||
identifier == "gl_FrontSecondaryColor" && version >= 130 || (identifier == "gl_FrontSecondaryColor" && version >= 130) ||
identifier == "gl_BackSecondaryColor" && version >= 130 || (identifier == "gl_BackSecondaryColor" && version >= 130) ||
identifier == "gl_SecondaryColor" && version >= 130 || (identifier == "gl_SecondaryColor" && version >= 130) ||
identifier == "gl_Color" && version >= 130 && language == EShLangFragment || (identifier == "gl_Color" && version >= 130 && language == EShLangFragment) ||
identifier == "gl_TexCoord") { identifier == "gl_TexCoord") {
// Find the existing symbol, if any. // Find the existing symbol, if any.
bool builtIn; bool builtIn;
@ -2347,7 +2347,7 @@ void TParseContext::addBlock(TSourceLoc loc, TTypeList& typeList, const TString*
TQualifier memberQualifier = typeList[member].type->getQualifier(); TQualifier memberQualifier = typeList[member].type->getQualifier();
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockDefaults.storage) if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockDefaults.storage)
error(loc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), ""); error(loc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), "");
if (currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()) if ((currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation()) || memberQualifier.isAuxiliary())
error(loc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), ""); error(loc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), "");
TBasicType basicType = typeList[member].type->getBasicType(); TBasicType basicType = typeList[member].type->getBasicType();
@ -2570,7 +2570,7 @@ TIntermNode* TParseContext::addSwitch(TSourceLoc loc, TIntermTyped* expression,
wrapupSwitchSubsequence(lastStatements, 0); wrapupSwitchSubsequence(lastStatements, 0);
if (expression == 0 || if (expression == 0 ||
expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint || (expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint) ||
expression->getType().isArray() || expression->getType().isMatrix() || expression->getType().isVector()) expression->getType().isArray() || expression->getType().isMatrix() || expression->getType().isVector())
error(loc, "condition must be a scalar integer expression", "switch", ""); error(loc, "condition must be a scalar integer expression", "switch", "");

View File

@ -63,7 +63,7 @@ public:
bool forwardCompatible = false, EShMessages messages = EShMsgDefault); bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
public: public:
bool parseShaderStrings(TPpContext&, char* strings[], int strLen[], int numStrings); bool parseShaderStrings(TPpContext&, char* strings[], size_t strLen[], int numStrings);
void parserError(const char *s); // for bison's yyerror void parserError(const char *s); // for bison's yyerror
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken, void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,

View File

@ -35,7 +35,7 @@
#include "../Include/PoolAlloc.h" #include "../Include/PoolAlloc.h"
#include "../Include/Common.h" #include "../Include/Common.h"
#include "Include/InitializeGlobals.h" #include "../Include/InitializeGlobals.h"
#include "osinclude.h" #include "osinclude.h"
namespace glslang { namespace glslang {

View File

@ -41,7 +41,7 @@
#include <string.h> #include <string.h>
#include "Scan.h" #include "Scan.h"
#include "Include/Types.h" #include "../Include/Types.h"
#include "SymbolTable.h" #include "SymbolTable.h"
#include "glslang_tab.cpp.h" #include "glslang_tab.cpp.h"
#include "ParseHelper.h" #include "ParseHelper.h"
@ -579,8 +579,8 @@ int TScanContext::tokenizeIdentifier()
case SWITCH: case SWITCH:
case DEFAULT: case DEFAULT:
if (parseContext.profile == EEsProfile && parseContext.version < 300 || if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < 130) (parseContext.profile != EEsProfile && parseContext.version < 130))
reservedWord(); reservedWord();
return keyword; return keyword;
@ -637,8 +637,8 @@ int TScanContext::tokenizeIdentifier()
case LAYOUT: case LAYOUT:
case SHARED: case SHARED:
if (parseContext.profile == EEsProfile && parseContext.version < 300 || if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < 140) (parseContext.profile != EEsProfile && parseContext.version < 140))
return identifierOrType(); return identifierOrType();
return keyword; return keyword;
@ -789,7 +789,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER2DRECTSHADOW: case SAMPLER2DRECTSHADOW:
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile || if (parseContext.profile == EEsProfile ||
parseContext.profile != EEsProfile && parseContext.version < 140) (parseContext.profile != EEsProfile && parseContext.version < 140))
reservedWord(); reservedWord();
return keyword; return keyword;
@ -797,8 +797,8 @@ int TScanContext::tokenizeIdentifier()
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version == 300) if (parseContext.profile == EEsProfile && parseContext.version == 300)
reservedWord(); reservedWord();
else if (parseContext.profile == EEsProfile && parseContext.version < 300 || else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < 130) (parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType(); return identifierOrType();
return keyword; return keyword;
@ -806,8 +806,8 @@ int TScanContext::tokenizeIdentifier()
return es30ReservedFromGLSL(130); return es30ReservedFromGLSL(130);
case SMOOTH: case SMOOTH:
if (parseContext.profile == EEsProfile && parseContext.version < 300 || if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < 130) (parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType(); return identifierOrType();
return keyword; return keyword;
@ -825,7 +825,7 @@ int TScanContext::tokenizeIdentifier()
case PRECISE: case PRECISE:
if (parseContext.profile == EEsProfile || if (parseContext.profile == EEsProfile ||
parseContext.profile != EEsProfile && parseContext.version < 400) (parseContext.profile != EEsProfile && parseContext.version < 400))
return identifierOrType(); return identifierOrType();
return keyword; return keyword;
@ -835,15 +835,15 @@ int TScanContext::tokenizeIdentifier()
return keyword; return keyword;
case PACKED: case PACKED:
if (parseContext.profile == EEsProfile && parseContext.version < 300 || if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < 330) (parseContext.profile != EEsProfile && parseContext.version < 330))
return reservedWord(); return reservedWord();
return identifierOrType(); return identifierOrType();
case RESOURCE: case RESOURCE:
{ {
bool reserved = parseContext.profile == EEsProfile && parseContext.version >= 300 || bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
parseContext.profile != EEsProfile && parseContext.version >= 420; (parseContext.profile != EEsProfile && parseContext.version >= 420);
return identifierOrReserved(reserved); return identifierOrReserved(reserved);
} }
case SUPERP: case SUPERP:
@ -906,8 +906,8 @@ int TScanContext::identifierOrReserved(bool reserved)
// but then got reserved by ES 3.0. // but then got reserved by ES 3.0.
int TScanContext::es30ReservedFromGLSL(int version) int TScanContext::es30ReservedFromGLSL(int version)
{ {
if (parseContext.profile == EEsProfile && parseContext.version < 300 || if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
parseContext.profile != EEsProfile && parseContext.version < version) { (parseContext.profile != EEsProfile && parseContext.version < version)) {
if (parseContext.forwardCompatible) if (parseContext.forwardCompatible)
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, ""); parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
@ -922,8 +922,8 @@ int TScanContext::es30ReservedFromGLSL(int version)
// showed up, both in an es version and a non-ES version. // showed up, both in an es version and a non-ES version.
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion) int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
{ {
if (parseContext.profile == EEsProfile && parseContext.version < esVersion || if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
parseContext.profile != EEsProfile && parseContext.version < nonEsVersion) { (parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
if (parseContext.forwardCompatible) if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, ""); parseContext.warn(loc, "using future keyword", tokenText, "");
@ -983,8 +983,8 @@ int TScanContext::firstGenerationImage()
if (parseContext.profile != EEsProfile && parseContext.version >= 420) if (parseContext.profile != EEsProfile && parseContext.version >= 420)
return keyword; return keyword;
if (parseContext.profile == EEsProfile && parseContext.version >= 300 || if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
parseContext.profile != EEsProfile && parseContext.version >= 130) { (parseContext.profile != EEsProfile && parseContext.version >= 130)) {
reservedWord(); reservedWord();
return keyword; return keyword;

View File

@ -37,14 +37,14 @@
#include "Versions.h" #include "Versions.h"
namespace glslang { namespace glslang {
// //
// A character scanner that seamlessly, on read-only strings, reads across an // A character scanner that seamlessly, on read-only strings, reads across an
// array of strings without assuming null termination. // array of strings without assuming null termination.
// //
class TInputScanner { class TInputScanner {
public: public:
TInputScanner(int n, const char* const i[], int L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { } TInputScanner(int n, const char* const i[], size_t L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { }
// return of -1 means end of strings, // return of -1 means end of strings,
// anything else is the next character // anything else is the next character
@ -65,7 +65,7 @@ public:
void advance() void advance()
{ {
++currentChar; ++currentChar;
if (currentChar >= lengths[currentSource]) { if (currentChar >= static_cast<int>(lengths[currentSource])) {
++currentSource; ++currentSource;
currentChar = 0; currentChar = 0;
while (currentSource < numSources && lengths[currentSource] == 0) while (currentSource < numSources && lengths[currentSource] == 0)
@ -100,7 +100,7 @@ public:
protected: protected:
int numSources; // number of strings in source int numSources; // number of strings in source
const char* const *sources; // array of strings const char* const *sources; // array of strings
const int *lengths; // length of each string const size_t *lengths; // length of each string
int currentSource; int currentSource;
int currentChar; int currentChar;
}; };

View File

@ -139,7 +139,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
symbolTable.push(); symbolTable.push();
const char* builtInShaders[2]; const char* builtInShaders[2];
int builtInLengths[2]; size_t builtInLengths[2];
builtInShaders[0] = builtIns.c_str(); builtInShaders[0] = builtIns.c_str();
builtInLengths[0] = builtIns.size(); builtInLengths[0] = builtIns.size();
@ -430,7 +430,7 @@ bool CompileDeferred(
GetThreadPoolAllocator().push(); GetThreadPoolAllocator().push();
// move to length-based strings, rather than null-terminated strings // move to length-based strings, rather than null-terminated strings
int* lengths = new int[numStrings]; size_t* lengths = new size_t[numStrings];
for (int s = 0; s < numStrings; ++s) { for (int s = 0; s < numStrings; ++s) {
if (inputLengths == 0 || inputLengths[s] < 0) if (inputLengths == 0 || inputLengths[s] < 0)
lengths[s] = strlen(shaderStrings[s]); lengths[s] = strlen(shaderStrings[s]);

View File

@ -103,7 +103,7 @@ TPpContext::~TPpContext()
FreeScanner(); FreeScanner();
} }
void TPpContext::setPreamble(const char* p, int l) void TPpContext::setPreamble(const char* p, size_t l)
{ {
if (p && l > 0) { if (p && l > 0) {
// preAmble could be a hard-coded string; make writable copy // preAmble could be a hard-coded string; make writable copy
@ -116,7 +116,7 @@ void TPpContext::setPreamble(const char* p, int l)
} }
} }
void TPpContext::setShaderStrings(char* s[], int l[], int n) void TPpContext::setShaderStrings(char* s[], size_t l[], int n)
{ {
strings = s; strings = s;
lengths = l; lengths = l;

View File

@ -102,8 +102,8 @@ public:
TPpContext(TParseContext&); TPpContext(TParseContext&);
virtual ~TPpContext(); virtual ~TPpContext();
void setPreamble(const char* preamble, int length); void setPreamble(const char* preamble, size_t length);
void setShaderStrings(char* strings[], int lengths[], int numStrings); void setShaderStrings(char* strings[], size_t lengths[], int numStrings);
const char* tokenize(TPpToken* yylvalpp); const char* tokenize(TPpToken* yylvalpp);
@ -219,12 +219,12 @@ public:
}; };
protected: protected:
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
int preambleLength; int preambleLength;
char** strings; // official strings of shader, starting a string 0 line 1 char** strings; // official strings of shader, starting a string 0 line 1
int* lengths; size_t* lengths;
int numStrings; // how many official strings there are int numStrings; // how many official strings there are
int currentString; // which string we're currently parsing (-1 for preamble) int currentString; // which string we're currently parsing (-1 for preamble)
// Scanner data: // Scanner data:
int mostRecentToken; // Most recent token seen by the scanner int mostRecentToken; // Most recent token seen by the scanner