Commit ca3457f1 by John Kessenich

glslang: Fix a few more warnings, and see it using nullptr causes anyone…

glslang: Fix a few more warnings, and see it using nullptr causes anyone problems (testing c++11 portability). git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31218 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent b06127c5
......@@ -1119,7 +1119,7 @@ bool TGlslangToSpvTraverser::visitSwitch(glslang::TVisit /* visit */, glslang::T
// handle the case where the last code segment is missing, due to no code
// statements between the last case and the end of the switch statement
if ((int)codeSegments.size() == valueIndexToSegment[caseValues.size() - 1])
codeSegments.push_back(0);
codeSegments.push_back(nullptr);
// make the switch statement
std::vector<spv::Block*> segmentBlocks; // returned, as the blocks allocated in the call
......
......@@ -801,7 +801,7 @@ EShLanguage FindLanguage(const std::string& name)
//
void CompileFile(const char* fileName, ShHandle compiler)
{
int ret;
int ret = 0;
char** shaderStrings = ReadFileData(fileName);
if (! shaderStrings) {
usage();
......@@ -826,12 +826,12 @@ void CompileFile(const char* fileName, ShHandle compiler)
for (int i = 0; i < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++i) {
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j) {
//ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
ret = ShCompile(compiler, shaderStrings, NumShaderStrings, 0, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
ret = ShCompile(compiler, shaderStrings, NumShaderStrings, nullptr, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
//const char* multi[12] = { "# ve", "rsion", " 300 e", "s", "\n#err",
// "or should be l", "ine 1", "string 5\n", "float glo", "bal",
// ";\n#error should be line 2\n void main() {", "global = 2.3;}" };
//const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
//ret = ShCompile(compiler, multi, 7, 0, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
//ret = ShCompile(compiler, multi, 7, nullptr, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
}
if (Options & EOptionMemoryLeakMode)
......@@ -919,28 +919,28 @@ char** ReadFileData(const char* fileName)
FILE *in;
int errorCode = fopen_s(&in, fileName, "r");
char *fdata;
int count = 0;
const int maxSourceStrings = 5;
char** return_data = (char**)malloc(sizeof(char *) * (maxSourceStrings+1));
if (errorCode) {
printf("Error: unable to open input file: %s\n", fileName);
return 0;
return nullptr;
}
while (fgetc(in) != EOF)
count++;
fseek(in, 0, SEEK_SET);
if (!(fdata = (char*)malloc(count+2))) {
char *fdata = (char*)malloc(count+2);
if (! fdata) {
printf("Error allocating memory\n");
return 0;
return nullptr;
}
if ((int)fread(fdata,1,count, in) != count) {
printf("Error reading input file: %s\n", fileName);
return 0;
return nullptr;
}
fdata[count] = '\0';
fclose(in);
......
......@@ -994,7 +994,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
return CompileDeferred(compiler, strings, numStrings, 0, EShOptNone, builtInResources, defaultVersion, forwardCompatible, messages, *intermediate);
return CompileDeferred(compiler, strings, numStrings, nullptr, EShOptNone, builtInResources, defaultVersion, forwardCompatible, messages, *intermediate);
}
const char* TShader::getInfoLog()
......
......@@ -481,8 +481,8 @@ void TParseContext::updateExtensionBehavior(const char* extension, const char* b
//
void TParseContext::fullIntegerCheck(TSourceLoc loc, const char* op)
{
profileRequires(loc, ENoProfile, 130, 0, op);
profileRequires(loc, EEsProfile, 300, 0, op);
profileRequires(loc, ENoProfile, 130, nullptr, op);
profileRequires(loc, EEsProfile, 300, nullptr, op);
}
//
......@@ -491,8 +491,8 @@ void TParseContext::fullIntegerCheck(TSourceLoc loc, const char* op)
void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
{
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 400, 0, op);
profileRequires(loc, ECompatibilityProfile, 400, 0, op);
profileRequires(loc, ECoreProfile, 400, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 400, nullptr, op);
}
} // end namespace glslang
......@@ -96,6 +96,10 @@ using namespace glslang;
}
%{
#pragma warning(disable : 4065)
#pragma warning(disable : 4127)
#pragma warning(disable : 4244)
#define parseContext (*pParseContext)
#define yyerror(context, msg) context->parserError(msg)
......
......@@ -835,7 +835,7 @@ const int baseAlignmentVec4Std140 = 16;
// Return the size and alignment of a scalar.
// The size is returned in the 'size' parameter
// Return value is the alignment of the type.
int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
{
switch (type.getBasicType()) {
case EbtDouble: size = 8; return 8;
......@@ -851,7 +851,7 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
//
// The size is returned in the 'size' parameter
// Return value is the alignment of the type.
int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
int TIntermediate::getBaseAlignment(const TType& type, int& size, bool std140)
{
int alignment;
......
......@@ -100,15 +100,15 @@ TPpContext::MemoryPool* TPpContext::mem_CreatePool(size_t chunksize, unsigned in
if (chunksize == 0)
chunksize = CHUNKSIZE;
if (align & (align - 1))
return 0;
return nullptr;
if (chunksize < sizeof(MemoryPool))
return 0;
return nullptr;
if (chunksize & (align - 1))
return 0;
return nullptr;
MemoryPool *pool = (MemoryPool*)malloc(chunksize);
if (! pool)
return 0;
return nullptr;
pool->next = 0;
pool->chunksize = chunksize;
......@@ -143,10 +143,12 @@ void* TPpContext::mem_Alloc(MemoryPool *pool, size_t size)
// request size is too big for the chunksize, so allocate it as
// a single chunk of the right size
ch = (struct chunk*)malloc(minreq);
if (!ch) return 0;
if (! ch)
return nullptr;
} else {
ch = (struct chunk*)malloc(pool->chunksize);
if (!ch) return 0;
if (! ch)
return nullptr;
pool->free = (uintptr_t)ch + minreq;
pool->end = (uintptr_t)ch + pool->chunksize;
}
......
......@@ -206,9 +206,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
}
}
} else if (ch == 'f' || ch == 'F') {
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, 0, "floating-point suffix");
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
if ((parseContext.messages & EShMsgRelaxedErrors) == 0)
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, 0, "floating-point suffix");
parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
if (! HasDecimalOrExponent)
parseContext.error(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
if (len < TPpToken::maxTokenLength)
......@@ -222,7 +222,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
str[len]='\0';
ppToken->dval = strtod(str, 0);
ppToken->dval = strtod(str, nullptr);
}
if (isDouble)
......@@ -687,24 +687,24 @@ const char* TPpContext::tokenize(TPpToken* ppToken)
int token = '\n';
for(;;) {
const char* tokenString = 0;
const char* tokenString = nullptr;
token = scanToken(ppToken);
ppToken->token = token;
if (token == EOF) {
missingEndifCheck();
return 0;
return nullptr;
}
if (token == '#') {
if (previous_token == '\n') {
token = readCPPline(ppToken);
if (token == EOF) {
missingEndifCheck();
return 0;
return nullptr;
}
continue;
} else {
parseContext.error(ppToken->loc, "preprocessor directive cannot be preceded by another token", "#", "");
return 0;
return nullptr;
}
}
previous_token = token;
......@@ -723,10 +723,10 @@ const char* TPpContext::tokenize(TPpToken* ppToken)
tokenString = ppToken->name;
else if (token == CPP_STRCONSTANT) {
parseContext.error(ppToken->loc, "string literals not supported", "\"\"", "");
tokenString = 0;
tokenString = nullptr;
} else if (token == '\'') {
parseContext.error(ppToken->loc, "character literals not supported", "\'", "");
tokenString = 0;
tokenString = nullptr;
} else
tokenString = GetAtomString(token);
......
......@@ -127,7 +127,7 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(int atom)
{
TSymbolMap::iterator it = symbols.find(atom);
if (it == symbols.end())
return 0;
return nullptr;
else
return it->second;
}
......
......@@ -367,7 +367,7 @@ public:
return base;
TIntermBinary* left = node->getLeft()->getAsBinaryNode();
if (! left)
return 0;
return nullptr;
return findBase(left);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment