diff --git a/Test/baseResults/xfbUnsizedArray.error.tese.out b/Test/baseResults/xfbUnsizedArray.error.tese.out new file mode 100644 index 000000000..df3495f1d --- /dev/null +++ b/Test/baseResults/xfbUnsizedArray.error.tese.out @@ -0,0 +1,35 @@ +xfbUnsizedArray.error.tese +ERROR: 0:4: 'xfb_offset' : unsized array in buffer 0 +ERROR: 1 compilation errors. No code generated. + + +Shader version: 430 +Requested GL_ARB_enhanced_layouts +in xfb mode +input primitive = isolines +vertex spacing = none +triangle order = none +using point mode +ERROR: node is still EOpNull! +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:? Linker Objects +0:? 'unsized' (layout( xfb_buffer=0 xfb_offset=0) out unsized 1-element array of 4-component vector of float) + + +Linked tessellation evaluation stage: + + +Shader version: 430 +Requested GL_ARB_enhanced_layouts +in xfb mode +input primitive = isolines +vertex spacing = equal_spacing +triangle order = ccw +using point mode +ERROR: node is still EOpNull! +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: +0:? Linker Objects +0:? 'unsized' (layout( xfb_buffer=0 xfb_offset=0) out 1-element array of 4-component vector of float) + diff --git a/Test/xfbUnsizedArray.error.tese b/Test/xfbUnsizedArray.error.tese new file mode 100644 index 000000000..a59069bb9 --- /dev/null +++ b/Test/xfbUnsizedArray.error.tese @@ -0,0 +1,8 @@ +#version 430 core +#extension GL_ARB_enhanced_layouts : require +layout(isolines, point_mode) in; +layout (xfb_offset = 0) out vec4 unsized[]; // error: unsized array + +void main() +{ +} diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index f2bc3152a..1ce6de4c6 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6210,11 +6210,13 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type) #ifndef GLSLANG_WEB if (qualifier.hasXfbOffset() && qualifier.hasXfbBuffer()) { - int repeated = intermediate.addXfbBufferOffset(type); - if (repeated >= 0) - error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer); - if (type.isUnsizedArray()) + if (type.isUnsizedArray()) { error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer); + } else { + int repeated = intermediate.addXfbBufferOffset(type); + if (repeated >= 0) + error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer); + } // "The offset must be a multiple of the size of the first component of the first // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index 1fc7d1f14..620be97c9 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -1802,7 +1802,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains return size; } - int numComponents; + int numComponents {0}; if (type.isScalar()) numComponents = 1; else if (type.isVector()) diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index bc573f3eb..d15107d31 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -236,6 +236,7 @@ INSTANTIATE_TEST_SUITE_P( "noMatchingFunction.frag", "constantUnaryConversion.comp", "xfbUnsizedArray.error.vert", + "xfbUnsizedArray.error.tese", "glsl.140.layoutOffset.error.vert", "glsl.430.layoutOffset.error.vert", "glsl.450.subgroup.frag",