Fix #287: pin down the io-array size before checking for out of range index.
This commit is contained in:
parent
6f03bfc733
commit
2184c2f21a
@ -8,7 +8,10 @@ out gl_PerVertex {
|
||||
float gl_CullDistance[3];
|
||||
};
|
||||
|
||||
layout(triangles) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_in[3].gl_Position; // ERROR, out of range
|
||||
gl_CullDistance[2] = gl_in[1].gl_CullDistance[2];
|
||||
}
|
||||
|
||||
@ -1,72 +1,83 @@
|
||||
450.geom
|
||||
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
||||
ERROR: 0:15: '[' : array index out of range '3'
|
||||
ERROR: 0:15: 'gl_Position' : no such field in structure
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 450
|
||||
invocations = -1
|
||||
max_vertices = -1
|
||||
input primitive = none
|
||||
input primitive = triangles
|
||||
output primitive = none
|
||||
0:? Sequence
|
||||
0:11 Function Definition: main( ( global void)
|
||||
0:11 Function Parameters:
|
||||
0:13 Sequence
|
||||
0:13 move second child to first child ( temp float)
|
||||
0:13 direct index (layout( stream=0) temp float CullDistance)
|
||||
0:13 gl_CullDistance: direct index for structure (layout( stream=0) out 3-element array of float CullDistance)
|
||||
0:13 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 Constant:
|
||||
0:13 3 (const uint)
|
||||
0:13 Constant:
|
||||
0:13 2 (const int)
|
||||
0:13 direct index ( temp float CullDistance)
|
||||
0:13 gl_CullDistance: direct index for structure ( in 3-element array of float CullDistance)
|
||||
0:13 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 'gl_in' ( in implicitly-sized array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 Constant:
|
||||
0:13 1 (const int)
|
||||
0:13 Constant:
|
||||
0:13 0 (const int)
|
||||
0:13 Constant:
|
||||
0:13 2 (const int)
|
||||
ERROR: node is still EOpNull!
|
||||
0:13 Function Definition: main( ( global void)
|
||||
0:13 Function Parameters:
|
||||
0:15 Sequence
|
||||
0:15 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:15 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:15 Constant:
|
||||
0:15 3 (const int)
|
||||
0:16 move second child to first child ( temp float)
|
||||
0:16 direct index (layout( stream=0) temp float CullDistance)
|
||||
0:16 gl_CullDistance: direct index for structure (layout( stream=0) out 3-element array of float CullDistance)
|
||||
0:16 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 Constant:
|
||||
0:16 3 (const uint)
|
||||
0:16 Constant:
|
||||
0:16 2 (const int)
|
||||
0:16 direct index ( temp float CullDistance)
|
||||
0:16 gl_CullDistance: direct index for structure ( in 3-element array of float CullDistance)
|
||||
0:16 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 Constant:
|
||||
0:16 1 (const int)
|
||||
0:16 Constant:
|
||||
0:16 0 (const int)
|
||||
0:16 Constant:
|
||||
0:16 2 (const int)
|
||||
0:? Linker Objects
|
||||
0:? 'gl_in' ( in implicitly-sized array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:? 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
|
||||
|
||||
Linked geometry stage:
|
||||
|
||||
ERROR: Linking geometry stage: At least one shader must specify an input layout primitive
|
||||
ERROR: Linking geometry stage: At least one shader must specify an output layout primitive
|
||||
ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
|
||||
|
||||
Shader version: 450
|
||||
invocations = 1
|
||||
max_vertices = -1
|
||||
input primitive = none
|
||||
input primitive = triangles
|
||||
output primitive = none
|
||||
0:? Sequence
|
||||
0:11 Function Definition: main( ( global void)
|
||||
0:11 Function Parameters:
|
||||
0:13 Sequence
|
||||
0:13 move second child to first child ( temp float)
|
||||
0:13 direct index (layout( stream=0) temp float CullDistance)
|
||||
0:13 gl_CullDistance: direct index for structure (layout( stream=0) out 3-element array of float CullDistance)
|
||||
0:13 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 Constant:
|
||||
0:13 3 (const uint)
|
||||
0:13 Constant:
|
||||
0:13 2 (const int)
|
||||
0:13 direct index ( temp float CullDistance)
|
||||
0:13 gl_CullDistance: direct index for structure ( in 3-element array of float CullDistance)
|
||||
0:13 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 'gl_in' ( in 2-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:13 Constant:
|
||||
0:13 1 (const int)
|
||||
0:13 Constant:
|
||||
0:13 0 (const int)
|
||||
0:13 Constant:
|
||||
0:13 2 (const int)
|
||||
ERROR: node is still EOpNull!
|
||||
0:13 Function Definition: main( ( global void)
|
||||
0:13 Function Parameters:
|
||||
0:15 Sequence
|
||||
0:15 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:15 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:15 Constant:
|
||||
0:15 3 (const int)
|
||||
0:16 move second child to first child ( temp float)
|
||||
0:16 direct index (layout( stream=0) temp float CullDistance)
|
||||
0:16 gl_CullDistance: direct index for structure (layout( stream=0) out 3-element array of float CullDistance)
|
||||
0:16 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 Constant:
|
||||
0:16 3 (const uint)
|
||||
0:16 Constant:
|
||||
0:16 2 (const int)
|
||||
0:16 direct index ( temp float CullDistance)
|
||||
0:16 gl_CullDistance: direct index for structure ( in 3-element array of float CullDistance)
|
||||
0:16 direct index ( temp block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:16 Constant:
|
||||
0:16 1 (const int)
|
||||
0:16 Constant:
|
||||
0:16 0 (const int)
|
||||
0:16 Constant:
|
||||
0:16 2 (const int)
|
||||
0:? Linker Objects
|
||||
0:? 'gl_in' ( in 2-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:? 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance})
|
||||
0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance})
|
||||
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
// For the version, it uses the latest git tag followed by the number of commits.
|
||||
// For the date, it uses the current date (when then script is run).
|
||||
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1958"
|
||||
#define GLSLANG_DATE "31-Mar-2017"
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1965"
|
||||
#define GLSLANG_DATE "03-Apr-2017"
|
||||
|
||||
@ -342,10 +342,8 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
||||
TIntermTyped* result = nullptr;
|
||||
|
||||
int indexValue = 0;
|
||||
if (index->getQualifier().isFrontEndConstant()) {
|
||||
if (index->getQualifier().isFrontEndConstant())
|
||||
indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
|
||||
checkIndex(loc, base->getType(), indexValue);
|
||||
}
|
||||
|
||||
variableCheck(base);
|
||||
if (! base->isArray() && ! base->isMatrix() && ! base->isVector()) {
|
||||
@ -353,10 +351,12 @@ 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().isFrontEndConstant() && index->getQualifier().isFrontEndConstant())
|
||||
} else if (base->getType().getQualifier().isFrontEndConstant() && index->getQualifier().isFrontEndConstant()) {
|
||||
// both base and index are front-end constants
|
||||
checkIndex(loc, base->getType(), indexValue);
|
||||
return intermediate.foldDereference(base, indexValue, loc);
|
||||
else {
|
||||
// at least one of base and index is variable...
|
||||
} else {
|
||||
// at least one of base and index is not a front-end constant variable...
|
||||
|
||||
if (base->getAsSymbolNode() && isIoResizeArray(base->getType()))
|
||||
handleIoResizeArrayAccess(loc, base);
|
||||
@ -364,6 +364,8 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
|
||||
if (index->getQualifier().isFrontEndConstant()) {
|
||||
if (base->getType().isImplicitlySizedArray())
|
||||
updateImplicitArraySize(loc, base, indexValue);
|
||||
else
|
||||
checkIndex(loc, base->getType(), indexValue);
|
||||
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
|
||||
} else {
|
||||
if (base->getType().isImplicitlySizedArray()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user