Don't try to swizzle void.

This commit is contained in:
Aaron Muir Hamilton 2017-10-17 08:11:33 +00:00
parent 856502cb1b
commit 5313613dd1
4 changed files with 44 additions and 1 deletions

View File

@ -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)

8
Test/invalidSwizzle.vert Normal file
View File

@ -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
}

View File

@ -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);

View File

@ -188,6 +188,7 @@ INSTANTIATE_TEST_CASE_P(
"structDeref.frag",
"structure.frag",
"swizzle.frag",
"invalidSwizzle.vert",
"syntaxError.frag",
"test.frag",
"texture.frag",