diff --git a/Test/100.frag b/Test/100.frag index 28b0ec42..672e969a 100644 --- a/Test/100.frag +++ b/Test/100.frag @@ -178,4 +178,20 @@ int agggf(float f); // ERROR, second prototype varying struct SSS { float f; } s; // ERROR +int vf(void); +int vf2(); +int vf3(void v); // ERROR +int vf4(int, void); // ERROR +int vf5(int, void v); // ERROR + +void badswizzle() +{ + vec3 a[5]; + a.y; // ERROR, no array swizzle + a.zy; // ERROR, no array swizzle + a.nothing; // ERROR + a.length(); // ERROR, not this version + a.method(); // ERROR +} + uniform samplerExternalOES badExt; // syntax ERROR diff --git a/Test/baseResults/100.frag.out b/Test/baseResults/100.frag.out index bf72cd8f..c3a0402f 100644 --- a/Test/baseResults/100.frag.out +++ b/Test/baseResults/100.frag.out @@ -67,8 +67,18 @@ ERROR: 0:167: 'highp' : overloaded functions must have the same parameter precis ERROR: 0:170: 'multiple prototypes for same function' : not supported for this version or the enabled extensions ERROR: 0:177: 'multiple prototypes for same function' : not supported for this version or the enabled extensions ERROR: 0:179: 'fragment-shader struct input' : not supported for this version or the enabled extensions -ERROR: 0:181: '' : syntax error -ERROR: 62 compilation errors. No code generated. +ERROR: 0:183: 'v' : illegal use of type 'void' +ERROR: 0:184: 'void' : cannot be an argument type except for '(void)' +ERROR: 0:185: 'v' : illegal use of type 'void' +ERROR: 0:185: 'void' : cannot be an argument type except for '(void)' +ERROR: 0:190: '.' : cannot apply to an array: y +ERROR: 0:191: '.' : cannot apply to an array: zy +ERROR: 0:192: '.' : cannot apply to an array: nothing +ERROR: 0:193: '.length' : not supported for this version or the enabled extensions +ERROR: 0:194: '.' : cannot apply to an array: method +ERROR: 0:194: 'a' : can't use function syntax on variable +ERROR: 0:197: '' : syntax error +ERROR: 72 compilation errors. No code generated. Shader version: 100 @@ -326,6 +336,16 @@ ERROR: node is still EOpNull! 0:175 Branch: Return with expression 0:175 Constant: 0:175 2 (const int) +0:187 Function Definition: badswizzle( (void) +0:187 Function Parameters: +0:? Sequence +0:190 'a' (5-element array of mediump 3-component vector of float) +0:191 'a' (5-element array of mediump 3-component vector of float) +0:192 'a' (5-element array of mediump 3-component vector of float) +0:193 Constant: +0:193 5 (const int) +0:194 Constant: +0:194 0.000000 0:? Linker Objects 0:? 'a' (3-element array of mediump int) 0:? 'uint' (mediump int) @@ -610,6 +630,16 @@ ERROR: node is still EOpNull! 0:175 Branch: Return with expression 0:175 Constant: 0:175 2 (const int) +0:187 Function Definition: badswizzle( (void) +0:187 Function Parameters: +0:? Sequence +0:190 'a' (5-element array of mediump 3-component vector of float) +0:191 'a' (5-element array of mediump 3-component vector of float) +0:192 'a' (5-element array of mediump 3-component vector of float) +0:193 Constant: +0:193 5 (const int) +0:194 Constant: +0:194 0.000000 0:? Linker Objects 0:? 'a' (3-element array of mediump int) 0:? 'uint' (mediump int) diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index 1111c073..d5508d41 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -11,9 +11,9 @@ ERROR: 0:21: 'assign' : l-value required (can't modify a const) ERROR: 0:28: 'length' : array must be declared with a size before using this method ERROR: 0:31: 'length' : incomplete method syntax ERROR: 0:32: 'length' : method does not accept any arguments -ERROR: 0:33: 'flizbit' : does not apply to this type: 7-element array of float +ERROR: 0:33: '.' : cannot apply to an array: flizbit ERROR: 0:33: '=' : cannot convert from '7-element array of float' to 'int' -ERROR: 0:34: 'flizbit' : does not apply to this type: 7-element array of float +ERROR: 0:34: '.' : cannot apply to an array: flizbit ERROR: 0:34: 'f' : can't use function syntax on variable ERROR: 0:34: 'a4' : redefinition ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 82e98553..d37e879e 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -697,6 +697,17 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped* return intermediate.addMethod(base, TType(EbtInt), &field, loc); } + // It's not .length() if we get to here. + + if (base->isArray()) { + error(loc, "cannot apply to an array:", ".", field.c_str()); + + return base; + } + + // It's neither an array nor .length() if we get here, + // leaving swizzles and struct/block dereferences. + TIntermTyped* result = base; if (base->isVector() || base->isScalar()) { if (base->isScalar()) {