From 5313613dd1aeebd96288b3748cd78ed5e2e41619 Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Tue, 17 Oct 2017 08:11:33 +0000 Subject: [PATCH] Don't try to swizzle void. --- Test/baseResults/invalidSwizzle.vert.out | 34 ++++++++++++++++++++++++++++++ Test/invalidSwizzle.vert | 8 +++++++ glslang/MachineIndependent/ParseHelper.cpp | 2 +- gtests/AST.FromFile.cpp | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Test/baseResults/invalidSwizzle.vert.out create mode 100644 Test/invalidSwizzle.vert diff --git a/Test/baseResults/invalidSwizzle.vert.out b/Test/baseResults/invalidSwizzle.vert.out new file mode 100644 index 0000000..f53974b --- /dev/null +++ b/Test/baseResults/invalidSwizzle.vert.out @@ -0,0 +1,34 @@ +invalidSwizzle.vert +ERROR: 0:6: 'xx' : does not apply to this type: global void +ERROR: 0:7: 'xy' : does not apply to this type: global void +ERROR: 2 compilation errors. No code generated. + + +Shader version: 420 +ERROR: node is still EOpNull! +0:5 Function Definition: main( ( global void) +0:5 Function Parameters: +0:6 Sequence +0:6 Function Call: f( ( global void) +0:7 Function Call: f( ( global void) +0:? Linker Objects +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + + +Linked vertex stage: + +ERROR: Linking vertex stage: No function definition (body) found: + f( + +Shader version: 420 +ERROR: node is still EOpNull! +0:5 Function Definition: main( ( global void) +0:5 Function Parameters: +0:6 Sequence +0:6 Function Call: f( ( global void) +0:7 Function Call: f( ( global void) +0:? Linker Objects +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + diff --git a/Test/invalidSwizzle.vert b/Test/invalidSwizzle.vert new file mode 100644 index 0000000..00b5625 --- /dev/null +++ b/Test/invalidSwizzle.vert @@ -0,0 +1,8 @@ +#version 420 + +void f(); + +void main() { + f().xx; // Scalar swizzle does not apply to void + f().xy; // Vector swizzle does not apply either +} \ No newline at end of file diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 33e35e8..48eff23 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -663,7 +663,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm // leaving swizzles and struct/block dereferences. TIntermTyped* result = base; - if (base->isVector() || base->isScalar()) { + if (base->getBasicType() != EbtVoid && (base->isVector() || base->isScalar())) { if (base->isScalar()) { const char* dotFeature = "scalar swizzle"; requireProfile(loc, ~EEsProfile, dotFeature); diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index b963337..d4f9005 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -188,6 +188,7 @@ INSTANTIATE_TEST_CASE_P( "structDeref.frag", "structure.frag", "swizzle.frag", + "invalidSwizzle.vert", "syntaxError.frag", "test.frag", "texture.frag", -- 2.7.4