Misc semantics fixes:

- don't allow pre-array object versions to return a struct containing an array 
 - special case -2147483648 / -1
 - include "~" in the full integer functionality checks
 - handle multiple function parameters having the same name



git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24010 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-12 01:02:51 +00:00
parent 09709c1521
commit 67c9f3a720
9 changed files with 118 additions and 22 deletions

View file

@ -165,9 +165,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
break;
case EbtInt:
if (rightUnionArray[i] == 0) {
if (rightUnionArray[i] == 0)
newConstArray[i].setIConst(0x7FFFFFFF);
} else
else if (rightUnionArray[i].getIConst() == -1 && unionArray[i].getIConst() == 0x80000000)
newConstArray[i].setIConst(0x80000000);
else
newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
break;

View file

@ -758,6 +758,8 @@ TFunction* TParseContext::handleFunctionDeclarator(TSourceLoc loc, TFunction& fu
}
}
arrayObjectCheck(loc, function.getType(), "array in function return type");
// All built-in functions are defined, even though they don't have a body.
if (symbolTable.atBuiltInLevel())
function.setDefined();
@ -831,26 +833,22 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(TSourceLoc loc, TFunct
TParameter& param = function[i];
if (param.name != 0) {
TVariable *variable = new TVariable(param.name, *param.type);
//
// Insert the parameters with name in the symbol table.
//
if (! symbolTable.insert(*variable)) {
error(loc, "redefinition", variable->getName().c_str(), "");
delete variable;
}
//
// Transfer ownership of name pointer to symbol table.
//
param.name = 0;
} else {
// Transfer ownership of name pointer to symbol table.
param.name = 0;
//
// Add the parameter to the HIL
//
paramNodes = intermediate.growAggregate(paramNodes,
intermediate.addSymbol(variable->getUniqueId(),
variable->getName(),
variable->getType(), loc),
loc);
// Add the parameter to the HIL
paramNodes = intermediate.growAggregate(paramNodes,
intermediate.addSymbol(variable->getUniqueId(),
variable->getName(),
variable->getType(), loc),
loc);
}
} else
paramNodes = intermediate.growAggregate(paramNodes, intermediate.addSymbol(0, "", *param.type, loc), loc);
}

View file

@ -441,7 +441,8 @@ unary_operator
: PLUS { $$.loc = $1.loc; $$.op = EOpNull; }
| DASH { $$.loc = $1.loc; $$.op = EOpNegative; }
| BANG { $$.loc = $1.loc; $$.op = EOpLogicalNot; }
| TILDE { $$.loc = $1.loc; $$.op = EOpBitwiseNot; }
| TILDE { $$.loc = $1.loc; $$.op = EOpBitwiseNot;
parseContext.fullIntegerCheck($1.loc, "bitwise not"); }
;
// Grammar Note: No '*' or '&' unary ops. Pointers are not supported.