|
|
|
|
@@ -484,7 +484,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
|
|
|
|
TIntermTyped* result = nullptr;
|
|
|
|
|
|
|
|
|
|
int indexValue = 0;
|
|
|
|
|
if (index->getQualifier().storage == EvqConst) {
|
|
|
|
|
if (index->getQualifier().isConstant()) {
|
|
|
|
|
indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
|
|
|
|
|
checkIndex(loc, base->getType(), indexValue);
|
|
|
|
|
}
|
|
|
|
|
@@ -495,7 +495,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
|
|
|
|
error(loc, " left of '[' is not of type array, matrix, or vector ", base->getAsSymbolNode()->getName().c_str(), "");
|
|
|
|
|
else
|
|
|
|
|
error(loc, " left of '[' is not of type array, matrix, or vector ", "expression", "");
|
|
|
|
|
} else if (base->getType().getQualifier().storage == EvqConst && index->getQualifier().storage == EvqConst)
|
|
|
|
|
} else if (base->getType().getQualifier().isFrontEndConstant() && index->getQualifier().isFrontEndConstant())
|
|
|
|
|
return intermediate.foldDereference(base, indexValue, loc);
|
|
|
|
|
else {
|
|
|
|
|
// at least one of base and index is variable...
|
|
|
|
|
@@ -503,7 +503,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
|
|
|
|
if (base->getAsSymbolNode() && isIoResizeArray(base->getType()))
|
|
|
|
|
handleIoResizeArrayAccess(loc, base);
|
|
|
|
|
|
|
|
|
|
if (index->getQualifier().storage == EvqConst) {
|
|
|
|
|
if (index->getQualifier().isConstant()) {
|
|
|
|
|
if (base->getType().isImplicitlySizedArray())
|
|
|
|
|
updateImplicitArraySize(loc, base, indexValue);
|
|
|
|
|
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
|
|
|
|
|
@@ -541,10 +541,10 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
|
|
|
|
} else {
|
|
|
|
|
// Insert valid dereferenced result
|
|
|
|
|
TType newType(base->getType(), 0); // dereferenced type
|
|
|
|
|
if (base->getType().getQualifier().storage == EvqConst && index->getQualifier().storage == EvqConst)
|
|
|
|
|
if (base->getType().getQualifier().isFrontEndConstant() && index->getQualifier().isFrontEndConstant())
|
|
|
|
|
newType.getQualifier().storage = EvqConst;
|
|
|
|
|
else
|
|
|
|
|
newType.getQualifier().storage = EvqTemporary;
|
|
|
|
|
newType.getQualifier().makePartialTemporary();
|
|
|
|
|
result->setType(newType);
|
|
|
|
|
|
|
|
|
|
if (anyIndexLimits)
|
|
|
|
|
@@ -587,7 +587,7 @@ void TParseContext::handleIndexLimits(const TSourceLoc& /*loc*/, TIntermTyped* b
|
|
|
|
|
(! limits.generalVariableIndexing && ! base->getType().getQualifier().isUniformOrBuffer() &&
|
|
|
|
|
! base->getType().getQualifier().isPipeInput() &&
|
|
|
|
|
! base->getType().getQualifier().isPipeOutput() &&
|
|
|
|
|
base->getType().getQualifier().storage != EvqConst) ||
|
|
|
|
|
! base->getType().getQualifier().isConstant()) ||
|
|
|
|
|
(! limits.generalVaryingIndexing && (base->getType().getQualifier().isPipeInput() ||
|
|
|
|
|
base->getType().getQualifier().isPipeOutput()))) {
|
|
|
|
|
// it's too early to know what the inductive variables are, save it for post processing
|
|
|
|
|
@@ -849,7 +849,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (fieldFound) {
|
|
|
|
|
if (base->getType().getQualifier().storage == EvqConst)
|
|
|
|
|
if (base->getType().getQualifier().isFrontEndConstant())
|
|
|
|
|
result = intermediate.foldDereference(base, member, loc);
|
|
|
|
|
else {
|
|
|
|
|
blockMemberExtensionCheck(loc, base, field);
|
|
|
|
|
@@ -2039,7 +2039,7 @@ void TParseContext::rValueErrorCheck(const TSourceLoc& loc, const char* op, TInt
|
|
|
|
|
//
|
|
|
|
|
void TParseContext::constantValueCheck(TIntermTyped* node, const char* token)
|
|
|
|
|
{
|
|
|
|
|
if (node->getQualifier().storage != EvqConst)
|
|
|
|
|
if (! node->getQualifier().isConstant())
|
|
|
|
|
error(node->getLoc(), "constant expression required", token, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2204,6 +2204,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
|
|
|
|
|
|
|
|
|
int size = 0;
|
|
|
|
|
bool constType = true;
|
|
|
|
|
bool specConstType = true;
|
|
|
|
|
bool full = false;
|
|
|
|
|
bool overFull = false;
|
|
|
|
|
bool matrixInMatrix = false;
|
|
|
|
|
@@ -2232,12 +2233,17 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
|
|
|
|
if (op != EOpConstructStruct && ! type.isArray() && size >= type.computeNumComponents())
|
|
|
|
|
full = true;
|
|
|
|
|
|
|
|
|
|
if (function[arg].type->getQualifier().storage != EvqConst)
|
|
|
|
|
if (! function[arg].type->getQualifier().isConstant())
|
|
|
|
|
constType = false;
|
|
|
|
|
if (! function[arg].type->getQualifier().isSpecConstant())
|
|
|
|
|
specConstType = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (constType)
|
|
|
|
|
if (constType) {
|
|
|
|
|
type.getQualifier().storage = EvqConst;
|
|
|
|
|
if (specConstType)
|
|
|
|
|
type.getQualifier().specConstant = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type.isArray()) {
|
|
|
|
|
if (function.getParamCount() == 0) {
|
|
|
|
|
@@ -3147,7 +3153,7 @@ void TParseContext::nonInitConstCheck(const TSourceLoc& loc, TString& identifier
|
|
|
|
|
//
|
|
|
|
|
if (type.getQualifier().storage == EvqConst ||
|
|
|
|
|
type.getQualifier().storage == EvqConstReadOnly) {
|
|
|
|
|
type.getQualifier().storage = EvqTemporary;
|
|
|
|
|
type.getQualifier().makeTemporary();
|
|
|
|
|
error(loc, "variables with qualifier 'const' must be initialized", identifier.c_str(), "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -4848,7 +4854,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|
|
|
|
if (! initializer) {
|
|
|
|
|
// error recovery; don't leave const without constant values
|
|
|
|
|
if (qualifier == EvqConst)
|
|
|
|
|
variable->getWritableType().getQualifier().storage = EvqTemporary;
|
|
|
|
|
variable->getWritableType().getQualifier().makeTemporary();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -4868,21 +4874,22 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Uniform and global consts require a constant initializer
|
|
|
|
|
if (qualifier == EvqUniform && initializer->getType().getQualifier().storage != EvqConst) {
|
|
|
|
|
// Uniforms require a compile-time constant initializer
|
|
|
|
|
if (qualifier == EvqUniform && ! initializer->getType().getQualifier().isFrontEndConstant()) {
|
|
|
|
|
error(loc, "uniform initializers must be constant", "=", "'%s'", variable->getType().getCompleteString().c_str());
|
|
|
|
|
variable->getWritableType().getQualifier().storage = EvqTemporary;
|
|
|
|
|
variable->getWritableType().getQualifier().makeTemporary();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (qualifier == EvqConst && symbolTable.atGlobalLevel() && initializer->getType().getQualifier().storage != EvqConst) {
|
|
|
|
|
// Global consts require a constant initializer (specialization constant is okay)
|
|
|
|
|
if (qualifier == EvqConst && symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
|
|
|
|
|
error(loc, "global const initializers must be constant", "=", "'%s'", variable->getType().getCompleteString().c_str());
|
|
|
|
|
variable->getWritableType().getQualifier().storage = EvqTemporary;
|
|
|
|
|
variable->getWritableType().getQualifier().makeTemporary();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Const variables require a constant initializer, depending on version
|
|
|
|
|
if (qualifier == EvqConst) {
|
|
|
|
|
if (initializer->getType().getQualifier().storage != EvqConst) {
|
|
|
|
|
if (! initializer->getType().getQualifier().isConstant()) {
|
|
|
|
|
const char* initFeature = "non-constant initializer";
|
|
|
|
|
requireProfile(loc, ~EEsProfile, initFeature);
|
|
|
|
|
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
|
|
|
|
|
@@ -4894,7 +4901,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|
|
|
|
//
|
|
|
|
|
// "In declarations of global variables with no storage qualifier or with a const
|
|
|
|
|
// qualifier any initializer must be a constant expression."
|
|
|
|
|
if (symbolTable.atGlobalLevel() && initializer->getType().getQualifier().storage != EvqConst) {
|
|
|
|
|
if (symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
|
|
|
|
|
const char* initFeature = "non-constant global initializer";
|
|
|
|
|
if (relaxedErrors())
|
|
|
|
|
warn(loc, "not allowed in this version", initFeature, "");
|
|
|
|
|
@@ -4910,7 +4917,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|
|
|
|
if (! initializer || ! initializer->getAsConstantUnion() || variable->getType() != initializer->getType()) {
|
|
|
|
|
error(loc, "non-matching or non-convertible constant type for const initializer",
|
|
|
|
|
variable->getType().getStorageQualifierString(), "");
|
|
|
|
|
variable->getWritableType().getQualifier().storage = EvqTemporary;
|
|
|
|
|
variable->getWritableType().getQualifier().makeTemporary();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|